-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathEUROCHF.py
More file actions
63 lines (59 loc) · 1.45 KB
/
EUROCHF.py
File metadata and controls
63 lines (59 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
try:
from ti_system import *
except Exception as e:
print ("no module ti_system")
def euro2chf(initeuro):
print("")
try:
neweuro = float(input("new euro value? (" + '{:.2f}'.format(initeuro) + "): "))
except Exception as e:
neweuro=initeuro
euro= neweuro
print("euro: " + '{:.2f}'.format(euro))
print("")
eurocount=float(input("amount euros "))
print("amount euros: ", eurocount)
chf=euro*eurocount
print ("costs in CHF: " + '{:.2f}'.format(chf))
return neweuro
def getEuroFromFile():
try:
file1 = open("eurostore.txt","r")
storedeuro = file1.read()
storedeuro = int(storedeuro)
file1.close()
except Exception as e:
storedeuro = .95
return storedeuro
def geteuro():
try:
xlist=recall_list("1")
storedeuro = float(xlist[0])
except NameError as e:
storedeuro=getEuroFromFile()
except Exception as e:
storedeuro = .83
saveeuro(storedeuro)
return storedeuro
def saveEuroToFile(iEuro):
file1 = open("eurostore.txt","w")
file1.write(str(iEuro))
file1.close()
def saveeuro(ieuro):
xlist=[]
xlist.append(ieuro)
try:
store_list("1",xlist)
except NameError as e:
saveEuroToFile(ieuro)
return
initeuro=geteuro()
while True:
try:
stopnow = input("stop program (1=y)? ")
if stopnow == "1":
break
initeuro = euro2chf(initeuro)
saveeuro(initeuro)
except Exception as e:
print(e)