1 changed files with 54 additions and 0 deletions
@ -0,0 +1,54 @@ |
|||
import random |
|||
|
|||
debug = False |
|||
|
|||
def debug_print(text): |
|||
if debug == True: |
|||
print(text) |
|||
|
|||
def hod_kostkou(): |
|||
return random.randint(1,6) |
|||
|
|||
def hod_dvema_kostkami(): |
|||
kostka1 = hod_kostkou() |
|||
kostka2 = hod_kostkou() |
|||
return kostka1+kostka2 |
|||
|
|||
print(f"Hod jednou kostkou: {hod_kostkou()}") #1-6 |
|||
print(f"Hod dvema kostkami: {hod_dvema_kostkami()}") # min:1+1 - max:6+6 ->>> 2-12 |
|||
|
|||
|
|||
########################################################### |
|||
|
|||
|
|||
def hod_specialni_kostkou(pocet_stran): |
|||
hodnota = random.randint(1,pocet_stran) |
|||
debug_print(f"Na D{pocet_stran} jsi hodil {hodnota}") |
|||
return hodnota |
|||
|
|||
def hod_vice_kostek(pocet_kostek,pocet_sten=6): |
|||
soucet = 0 |
|||
for i in range(pocet_kostek): |
|||
soucet += hod_specialni_kostkou(pocet_sten) |
|||
return soucet |
|||
|
|||
print(hod_specialni_kostkou(20)) |
|||
print(f"Hod 4x D6: {hod_vice_kostek(4)}") |
|||
print(f"Hod 3x D10: {hod_vice_kostek(3,10)}") |
|||
print(f"Hod 5x D20: {hod_vice_kostek(5,20)}") |
|||
|
|||
######################################################## |
|||
|
|||
def vyber_planetu(): |
|||
planety = ["Merkur","Venuše","Země","Mars", |
|||
"Jupiter","Staturn","Uran","Neptun"] |
|||
return random.choice(planety) |
|||
|
|||
def vytvor_nahodny_seznam(delka,minimum,maximum): |
|||
seznam = [] |
|||
for i in range(delka): |
|||
seznam.append(random.randint(minimum,maximum)) |
|||
return seznam |
|||
|
|||
print(f"Nahodná planeta: {vyber_planetu()}") |
|||
print(f"Nahodný seznam 5 čísel: {vytvor_nahodny_seznam(5,1,100)}") |
|||
Loading…
Reference in new issue