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']
'x
'
Např. pro vstup 10 vypadá výsledek takto:
| | | | | | | | | ------------------- |x| |x| |x| |x| |x ------------------- | |x| | |x| | |x| ------------------- |x| |x| |x| |x| |x ------------------- | | | |x| | | | |x ------------------- |x|x|x| |x| |x|x|x ------------------- | | | | | |x| | | ------------------- |x| |x| |x| |x| |x ------------------- | |x| | |x| | |x| ------------------- |x| |x|x|x| |x| |x
jedenmiliondvestepadesatsedmtisictristasedmdesatpet
1257375
2543210
dvamilionypetsetctyricettritisicdvestedeset
jeden, dva, tri, ctyri, pet, sest, sedm, osm, devet, deset, jedenact, dvanact, trinact, ctrnact, patnact, sestnact, sedmnact, osmnact, devatenact, dvacet, tricet, ctyricet, padesat, sedesat, sedmdesat, osmdesat, devadesat, sto, dveste, trista, ctyrista, petset, sestset, sedmset, osmset, devetset, tisic, tisice, milion, miliony, milionu