-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheggs.py
65 lines (53 loc) · 1.64 KB
/
eggs.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
# I'm going to solve a exercise called 'huevos a la copa'
import math
def vn(message):
while True:
try:
text = float(input(message))
return text
except ValueError:
print("just number, try again")
def string_validation(message):
while True:
text = input(message)
if text in ("s", "y", "n", "yes", "yeah", "no", "yep", "nop", "not", "si"):
return text
else:
print("type \'y\' or \'n\', please try again")
continue
def solve_exercise():
T_0 = vn("type the original temperature: ")
M = 47
c = 3.7
p = 1.038
K = 0.0054
PI = math.pi
E = math.e
T_w = 100
T_y = 70
ln = math.log(((T_0 - T_w) / (T_y - T_w)) * 0.76, E)
t = ((math.pow(M, 2 / 3) * c * math.pow(p, 1 / 2)) / (K * math.pow(PI, 2) * math.pow(4 * PI / 3, 2 / 3))) * (ln)
# so convert from second to minute and hours
minute = t / 60
hour = minute / 60
print("""
we know the maxim temperature is 70 °C for the yem
and we need the following time:
""")
print(t, "in seconds")
print(minute, "in minutes")
print(hour, "in hour")
def run():
# run the program
solve_exercise()
# ask if they want to use again
while True:
question = string_validation("Do you want to use the program again?(s/n): ")
if question in ("y", "yes", "yep", "yeah", "s", "si"):
print("HELLO AGAIN")
solve_exercise()
elif question in ("n", "no", "not", "nop"):
print("GOOD BYE, HAVE A NICE DAY")
break
if __name__ == '__main__':
run()