-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatineta.py
More file actions
105 lines (69 loc) · 2.57 KB
/
Copy pathpatineta.py
File metadata and controls
105 lines (69 loc) · 2.57 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
"""
Electric scooter cost
"""
print("--- Electric scooter cost validation ---")
def kilometres_information():
record = input("¿Do you wish to record km? (Y / N): ").lower()
maintenance_cost = 250_000
maintance_km = 800
route = []
while record == "y":
try:
path = float(input("How many kilometres will you cover today?: "))
if path <= 0:
print("That information can not be recorded.")
continue
else:
route.append(path)
except ValueError:
print("It is just possible written numbers.")
record = input("¿Do you wish to record km? (Y / N): ").lower()
return route, maintenance_cost, maintance_km
def cost(kilometres, maintance_cost, km_mant):
maintance_per_km = maintance_cost / km_mant
print(f"The km cost is: {maintance_per_km}")
results = []
for km in kilometres:
km_cost = maintance_per_km * km
results.append(f"El costo de {km} km es: {km_cost:.0f}")
set_limpio = set(results)
return set_limpio
def total_distance(total_kilometres, mant_cost, km_mant):
addition = sum(total_kilometres)
if addition > 0:
distance = (mant_cost * addition) / km_mant
return (
f"A total of {addition} km was covered at a total cost of: {distance:.0f} pesos"
)
def main():
print("\n---Menu---")
print("1. log mileage")
print("2. View the cost of each recorded kilometer.")
print("3. View the cost of total distances")
print("4. Leave")
option = int(input("Enter an option from 1 to 4 "))
while option < 1 or option > 3:
print("Type a number from 1 to 4")
while option >= 1 and option <= 3:
match option:
case 1:
distance_list, mant_cost, km_mant = kilometres_information()
print(f"The recorded values are: {distance_list}")
case 2:
check = cost(distance_list, mant_cost, km_mant)
print(f"{check}")
case 3:
total_path = total_distance(distance_list, mant_cost, km_mant)
print(f"{total_path}")
case 4:
print("Leaving...")
break
case _:
print("Error. Tpye a number from 1 to 3.")
print("\n---Menu---")
print("1. log mileage")
print("2. View the cost of each recorded kilometer.")
print("3. View the cost of total distances")
print("4. Leave")
option = int(input("Enter an option from 1 to 4 "))
main()