Show pageOld revisionsBacklinksExport to PDFBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== 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> <code python> def vratiClan(x,y): try: ret=x[y] except: ret="Neispravni indeks!" return ret </code> <code python> def vratiClan(x,y): try: ret=x[y] except TypeError: ret="Neispravni indeks!" except: ret="Indeks izvan raspona!" return ret </code> <code python> def vratiClan(x,*argy): i=0 for y in argy: i+=1 try: ret=x[y] except TypeError: ret="Neispravni indeks!" except: ret="Indeks izvan raspona!" print(str(i)+": "+str(ret)) </code> <code python> import csv def zapis(a): with open("out.csv", mode='w') as fout: fwr = csv.writer(fout,delimiter=';') for row in a: fwr.writerow(row) </code> <code python> import csv def zapis(a,f,d): try: with open(f+".csv", mode='w') as fout: fwr = csv.writer(fout,delimiter=d) for row in a: fwr.writerow(row) return True except: return False </code> <code python> import csv def prov(f): with open(f, mode='r') as fin: fre = csv.reader(fin,delimiter=";") for row in fre: a=0 for col in row: try: a+=float(col.replace(',','.')) except: err="err" if a<5: ret="nije OK" else: ret="OK" print(row[0]+" "+row[1]+":\t "+ret) </code> development/python/examples_10.txt Last modified: 2020/01/09 08:26by 127.0.0.1