forked from karl03/efficiency-calc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEfficiency Calculator1.2.py
71 lines (52 loc) · 1.87 KB
/
Efficiency Calculator1.2.py
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
totdist = 0
totdistavg = 0
totdistnow = 0
remdist = 0
remdistavg = 0
eff = 0
avgeff = 0
effneed = 0
dist = 0
cap = 0
ucap = 0
distout = 0
distfurth = 0
getback = False
#Efficiency = mAh / Km
while True: #Starting infinite loop
cap = int(input("Battery capacity in mAh?")) #Getting total battery capacity
while eff == 0:
eff = int(input("What is current efficiency (mah/km)?"))
if eff == 0:
print("Please enter efficiency \n")
dist = int(input("How many kilometres travelled?"))
distout = int(input("How many kilometres out?"))
ucap = int(input("Battery mAh used?"))
if cap > 0 and eff > 0:
totdist = cap / eff
if cap - ucap > 0 and eff > 0:
remdist = (cap - ucap) / eff
if ucap > 0 and dist > 0:
avgeff = ucap / dist
if cap > 0 and avgeff > 0:
totdistavg = cap / avgeff
if cap - ucap > 0 and avgeff > 0:
remdistavg = (cap - ucap) / avgeff
if distout < remdist:
getback = True
else:
getback = False
print("Can you get back: " + str(getback))
effneed = (cap - ucap) / distout
print("Results: \n")
print("Average efficiency so far is: " + str(avgeff) + "mAh/Km")
print("Total distance under current efficiency is: " + str(totdist) + "km")
print("Total distance under average efficiency is: " + str(totdistavg) + "km")
print("Remaining distance under current efficiency is: " + str(remdist) + "km")
print("Remaining distance under average efficiency is: " + str(remdistavg) + "km")
if getback == True:
distfurth = (remdist + distout) / 2
print("You can go " + str(distfurth) + "km further. \n")
else:
print("You need efficiency lower than: " + str(effneed) + " to get back \n")
eff = 0