no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | development:python:examples_10 [2020/01/09 08:26] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Python examples 10 ====== | ||
+ | <code python> | ||
+ | def funk(x,y): | ||
+ | try: | ||
+ | ret=x/y | ||
+ | except ZeroDivisionError: | ||
+ | ret="y ne moze biti 0!" | ||
+ | except TypeError: | ||
+ | ret="x i y moraju biti brojevi!" | ||
+ | return ret | ||
+ | </ | ||
+ | <code python> | ||
+ | def vratiClan(x, | ||
+ | try: | ||
+ | ret=x[y] | ||
+ | except: | ||
+ | ret=" | ||
+ | return ret | ||
+ | </ | ||
+ | |||
+ | <code python> | ||
+ | def vratiClan(x, | ||
+ | try: | ||
+ | ret=x[y] | ||
+ | except TypeError: | ||
+ | ret=" | ||
+ | except: | ||
+ | ret=" | ||
+ | return ret | ||
+ | </ | ||
+ | |||
+ | <code python> | ||
+ | def vratiClan(x, | ||
+ | i=0 | ||
+ | for y in argy: | ||
+ | i+=1 | ||
+ | try: | ||
+ | ret=x[y] | ||
+ | except TypeError: | ||
+ | ret=" | ||
+ | except: | ||
+ | ret=" | ||
+ | print(str(i)+": | ||
+ | </ | ||
+ | |||
+ | <code python> | ||
+ | import csv | ||
+ | def zapis(a): | ||
+ | with open(" | ||
+ | fwr = csv.writer(fout, | ||
+ | for row in a: | ||
+ | fwr.writerow(row) | ||
+ | </ | ||
+ | |||
+ | <code python> | ||
+ | import csv | ||
+ | def zapis(a, | ||
+ | try: | ||
+ | with open(f+" | ||
+ | fwr = csv.writer(fout, | ||
+ | for row in a: | ||
+ | fwr.writerow(row) | ||
+ | return True | ||
+ | except: | ||
+ | return False | ||
+ | </ | ||
+ | |||
+ | <code python> | ||
+ | import csv | ||
+ | def prov(f): | ||
+ | with open(f, mode=' | ||
+ | fre = csv.reader(fin, | ||
+ | for row in fre: | ||
+ | a=0 | ||
+ | for col in row: | ||
+ | try: | ||
+ | a+=float(col.replace(',',' | ||
+ | except: | ||
+ | err=" | ||
+ | if a<5: | ||
+ | ret=" | ||
+ | else: | ||
+ | ret=" | ||
+ | print(row[0]+" | ||
+ | </ |