-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStandard_enthalpy_formation.py
49 lines (41 loc) · 1.81 KB
/
Standard_enthalpy_formation.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
def standard_enthalpy_formation():
global delta_h_final
class color:
PURPLE = '\033[95m'
CYAN = '\033[96m'
DARKCYAN = '\033[36m'
BLUE = '\033[94m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
RED = '\033[91m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
END = '\033[0m'
products_value = []
products = int(input(color.BOLD + color.PURPLE + 'How many products do you have for Delta H: \n' + color.END))
intital = 0
question_number = 1
while intital < products:
moles_p = float(input(color.RED + f'How many moles for product #{question_number}: \n' + color.END))
delta_s_value_p = float(input(color.UNDERLINE + f'What is the H° value for product #{question_number}:\n' + color.END))
Sproduct = moles_p * delta_s_value_p
question_number += 1
products_value.extend([Sproduct])
intital += 1
if intital == products:
break
reactants_value=[]
intital = 0
reactants = int(input(color.BOLD + color.PURPLE + 'How many reactants do you have for Delta H?: \n' + color.END))
question_number = 1
while intital < reactants:
moles_r = float(input(color.RED + f'How many moles for reactant #{question_number}: \n' + color.END))
delta_s_value_r = float(input(color.UNDERLINE + f'What is the H° value for reactant #{question_number}:\n' + color.END))
Sreactant = moles_r * delta_s_value_r
question_number += 1
reactants_value.extend([Sreactant])
intital += 1
if intital == reactants:
break
delta_h_final = (sum(products_value) - sum(reactants_value))
print(color.BOLD + f'''Your H°rxn is {delta_h_final:.3f} (kJ*K)''' + color.END)