Search
Při programování často potřebujeme vykonat určité operace opakovaně. K tomu se hodí tzv. funkce.
def
def jmenoFunkce( parametry ): telo_funkce
Maximum ze dvou čísel:
def maximum(x,y): if x>y: return x else: return y
return
max = maximum(2,0.5) print(max) # nebo rovnou muzeme predat jiné funkci a = 6 b = 7 print("Maximum z ",a," a ", b, " je ", maximum(a,b))
def hello(): print("Hello World!")
hello()
def maximum2(x,y): if (x > y): return x, True else: return y, False
maxValue, info = maximum2(5,6) #zkusime predat printu: print("Maximum z 5,6 je ", maximum2(5,6))
quit()
if (spatny_vstup): quit()
input()
print( argumenty )
int( argument )
float( argument )
str( argument )
soucet_delitelu
gcd1(a,b)
gcd2(a,b)
ord('A')
chr(65)
convert_num_to_month
convert_month_to_num
month=['leden','unor','brezen','duben','kveten','cerven','cervenec','srpen','zari','rijen','listopad','prosinec']
min(a,b)
max(a,b)
area(radius)
d2r(angle)
r2d(angle)
normalize(angle)
for
while
x
chr(x)
Např. pro vstup
3 4484386 5430482 997155 6818895 2444051 6275419
:-)
pro vstup
9 1334386 13553534 3422019 12611931 8627474 6240422 12426219 12740481 13055039 7863151 9461235 9289245 12206332 15916244 6835579 14041121 3957597 11286009
Rozumite?
10 12994044 8108268 14877663 11703507 1093472 1825888 4053122 8115466 17435933 18487747 1926688 904864 17461286 15207014 19130135 15972695 15720953 4226951 3450782 91862
To je vse.
1.11.1958
the first of November onethousandninehundredfiftyeight
ERROR
the
of
.
the, first, second, third, th, fifth, eighth, ninth, twelfth, twentieth, thirtieth, of, January, February, March, April, May, June, July, August, September, October, November, December, one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, nineteen, twenty, thirty, forty, fifty, sixty, seventy, eighty, ninety, hundred, thousand
1000
onethousand
120
onehundredtwenty
Vstup: 31.12.3219 Výstup: the thirty-first of December threethousandtwohundrednineteen
Vstup: the twenty-ninth of February onethousandtwohundredthirtyfour Výstup: 29.2.1234
Vstup: 2.9.5.1234 Výstup: ERROR
Vstup: the fivetwentieth of January twenty Výstup: ERROR
Vstup: the twentieth of January twentyten Výstup: ERROR