forked from lasanthasuresh/code_quality_assignment_2023
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtravel_cost_calculator.py
More file actions
49 lines (37 loc) · 1.05 KB
/
travel_cost_calculator.py
File metadata and controls
49 lines (37 loc) · 1.05 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
from csv import *
a = {}
b = {}
c = {}
def lhr(file):
with open(file) as h:
r = reader(h)
for row in r:
a[row[0]] = float(row[1])
def ler(file):
with open(file) as e:
r = reader(e)
for row in r:
b[row[0].upper()] = float(row[1]) * 1
def lfr(file):
with open(file) as f:
r = reader(f)
for row in r:
c[row[0]] = float(row[1])
def main():
lhr('data/hotel_rates.csv')
ler('data/exchange_rates.csv')
lfr('data/flight_costs.csv')
d = input("Enter your destination: ").upper()
f = c.get(d, 0.0)
h = a.get(d, 0.0)
days = int(input("Enter your stay duration in days: "))
h *= days
total = f + h
print(f"Flight cost: USD {f:.2f}")
print(f"Hotel cost for {days} days: USD {h:.2f}")
print(f"Total: USD {total:.2f}")
currency = input(f"Select your currency for final price estimation ({', '.join(b.keys())}): ")
p = total * b[currency]
print(f"Total in {currency}: {p:.2f}")
if __name__ == "__main__":
main()