Created
April 11, 2022 18:17
-
-
Save vlna/55ea6781673704c78f489f736f4de422 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import randrange | |
tah_dict = {0: 'kámen', 1: 'nůžky', 2: 'papír'} | |
res_dict = {-2: 'hráč', -1: 'poč', 0: 'remíza', 1: 'hráč', 2: 'poč'} | |
def PC(): | |
return randrange(3) | |
def hrac(): | |
while True: | |
tah_hrace = int(input("Zvol si číslo - (0) kámen, (1) nůžky nebo (2) papír: ")) | |
if tah_hrace in [0, 1, 2]: | |
return tah_hrace | |
else: | |
print("Musíš si vybrat číslo zastupující libovolný znak!") | |
def tah(promenna): | |
return tah_dict[promenna] | |
def kombinace(pocitac, hrac): | |
return res_dict[pocitac - hrac] | |
def kamen_nuzky_papir(): | |
tah_pc = PC() | |
tah_hrace = hrac() | |
vysledek = kombinace(tah_pc, tah_hrace) | |
veta_dict = {'remíza': f'Počítač zvolil {tah(tah_pc)} a hráč vybral též {tah(tah_hrace)}, proto je výsledkem remíza!', | |
'poč': f'Počítač zvolil {tah(tah_pc)} a hráč vybral {tah(tah_hrace)}, proto vyhrál počítač.', | |
'hráč': f'Počítač zvolil {tah(tah_pc)}, ale hráč vybral {tah(tah_hrace)}, proto vyhrál hráč. Dobrá práce!'} | |
print(veta_dict[vysledek]) | |
kamen_nuzky_papir() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment