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 | |
# Házím 6 kostkami, vypíšu nejvyšší hod | |
# vím kolikrát chci něco udělat -> for cyklus | |
maximum = 0 | |
for hod in range(6): | |
hodnota = randrange(1, 7) | |
print(hodnota) | |
if maximum < hodnota: | |
maximum = hodnota |
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
def vrat_rok(data): | |
return int(data[-4:]) | |
def spocitej_vek(rok): | |
return 2019 - rok | |
def vrat_cele_jmeno(data): | |
return data[:-5] |
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
def moje_funkce1(): | |
"tato funkce nic nevypíše a nic nevrací" | |
print('-'*20, 'moje_funkce1()', '-'*20) | |
print('Funkce vratila:', moje_funkce1()) | |
def moje_funkce2(): | |
"tato funkce vypíše ahoj a nic nevrací" |
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
def vypis_hezky_nasobilku(maximum): | |
for radek in range(maximum): | |
for sloupec in range(maximum): | |
# formátování viz https://naucse.python.cz/2019/pyladies-praha-jaro-ntk/beginners/str/ | |
# Do {} lze zapsat, jak má výstup vypadat viz https://pyformat.info/ | |
# : - pomocný znak, > - zarovnat vpravo, 3 - šířka na 3 znaky | |
print('{:>3}'.format(radek * sloupec), end=' ') | |
print() | |
NewerOlder