Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- import os
- def calculate (ev1, av2):
- ev2 = float(math.log(pow(av2,2),2))
- rst = float(ev1 - ev2)
- if rst < 0:
- rst = float(abs(rst))
- result = float(pow(2,rst))
- return result
- def check(stringa):
- c = 0
- i = 0
- while i < len(stringa):
- car = stringa[i:i+1]
- if car == "0":
- c = c + 1
- if car == "1":
- c = c + 1
- if car == "2":
- c = c + 1
- if car == "3":
- c = c + 1
- if car == "4":
- c = c + 1
- if car == "5":
- c = c + 1
- if car == "6":
- c = c + 1
- if car == "7":
- c = c + 1
- if car == "8":
- c = c + 1
- if car == "9":
- c = c + 1
- if car == ".":
- c = c + 1
- i = i + 1
- if c == len(stringa):
- return True
- if c <> len(stringa):
- return False
- def converti(tempo):
- if tempo > 3600:
- ore = int(tempo / 3600)
- temporest = tempo - (ore * 3600)
- minute = int(temporest / 60)
- sec = tempo - ((ore * 3600) + (minute * 60))
- result = str(ore) + "h" + str(minute) + "m" + str(sec) + "s"
- return result
- if tempo < 3600:
- minute = int(tempo / 60)
- sec = tempo - (minute * 60)
- result = str(minute) + "m" + str(sec) + "s"
- return result
- global dia
- global tempo1
- global num
- global den
- global av1
- global av2
- global temp1
- global strnum
- global strden
- global switch
- global ev2a,ev2b
- global ev2ai,ev2bi
- global ev1i
- global result
- dia = [1,1.2,1.4,1.7,1.8,2,2.4,2.8,3.3,3.4,4,4.8,5.6,6.7,8,9.5,11,13,16,19,22]
- os.system('clear')
- switch = False
- av1 = input("Diaframma a tutta apertura: ")
- temp1 = raw_input("Tempo a tutta apertura: ")
- if len(temp1) < 1: exit()
- if av1 < 0: exit()
- if temp1[len(temp1)-1:len(temp1)] == ".": exit()
- if temp1[len(temp1)-1:len(temp1)] == "/": exit()
- temp1 = temp1.replace("//", "/")
- i = 0
- while i < len(temp1):
- i = i + 1
- if temp1[i:i+1] == "/":
- switch = True
- strnum = temp1[0:i]
- strden = temp1[i+1:len(temp1)]
- if check(strnum) == False:
- exit()
- if check(strden) == False:
- exit()
- num = float(strnum)
- den = float(strden)
- if switch == True:
- tempo1 = num / den
- ev1 = (pow(av1,2)) / tempo1
- ev1 = math.log(ev1,2)
- ev1i = int(ev1)
- print "EV: " + str(ev1)
- print ""
- for i in range(len(dia)):
- av2 = dia[i]
- if av2 <> av1:
- tempo2 = calculate(ev1,av2)
- ev2a = (pow(av2,2)) / tempo2
- ev2a = math.log(ev2a,2)
- ev2ai = int(ev2a)
- ev2b = (pow(av2,2)) / (1/tempo2)
- ev2b = math.log(ev2b,2)
- ev2bi = int(ev2b)
- if ev2ai == ev1i:
- print str(tempo2) + " sec @" + str(av2) + " EV: " + str(ev2a)
- else:
- if tempo2 < 2:
- tempo2 = 1 / tempo2
- print str(tempo2) + " sec @" + str(av2) + " EV: " + str(ev2b)
- else:
- print "1/" + str(tempo2) + " sec @" + str(av2) + " EV: " + str(ev2b)
- if switch == False:
- if check(temp1) == False:
- exit()
- tempo1 = float(temp1)
- ev1 = (pow(av1,2)) / tempo1
- ev1 = math.log(ev1,2)
- ev1ai = int(ev1)
- print "EV: " + str(ev1)
- print ""
- for i in range(len(dia)):
- av2 = dia[i]
- if av2 <> av1:
- tempo2 = calculate(ev1,av2)
- ev2a = (pow(av2,2)) / tempo2
- ev2a = math.log(ev2a,2)
- ev2ai = int(ev2a)
- ev2b = (pow(av2,2)) / (1/tempo2)
- ev2b = math.log(ev2b,2)
- ev2bi = int(ev2b)
- if ev2ai == ev1ai:
- if tempo2 < 60:
- print str(tempo2) + " sec @" + str(av2) + " EV: " + str(ev2a)
- else:
- result = converti(tempo2)
- print result + " @" + str(av2) + " EV: " + str(ev2a)
- if ev2bi == ev1ai:
- print "1/" + str(tempo2) + " sec @" + str(av2) + " EV: " + str(ev2b)
- print ""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement