-
Notifications
You must be signed in to change notification settings - Fork 0
/
Chemistry_Formula_Calculator.py
75 lines (66 loc) · 2.18 KB
/
Chemistry_Formula_Calculator.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
72
73
74
75
#A launcher to run your programs in a nicer looking way
import os
import sys
options = """
1. Density given Mass and Volume
2. Volume given Density and Mass
3. Mass given Volume and Density
4. Work given Force and Distance
5. Force given Distance and Work
6. Distance given Work and Force
7. Atoms from Grams
8. Atoms from Moles
9. Moles from Atoms
10. Moles from Grams
11. Grams from Atoms
12. Grams from Moles
13. Find the moles or grams needed to ballance the reaction
"""
print("Welcome to the formula calculator".center(71, "!"))
print("\nPlease choose one of the following to calculate:")
print(options)
optionalNums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
#Keep asking to run programs until the user is done
while True:
try:
choice = int(input("Choose a program by number -->"))
except:
while True:
print("Invalid Choice. Valid choices are a number from 1 to 6.")
choice = input("try again -->")
if (choice.isnumeric() and int(choice) in optionalNums):
break
if (choice == 1):
os.system("python density.py")
elif (choice == 2):
os.system("python volume.py")
elif (choice == 3):
os.system("python mass.py")
elif (choice == 4):
os.system("python work.py")
elif (choice == 5):
os.system("python force.py")
elif (choice == 6):
os.system("python distance.py")
elif (choice == 7):
os.system("python atomsFromGrams.py")
elif (choice == 8):
os.system("python atomsFromMoles.py")
elif (choice == 9):
os.system("python molesFromAtoms.py")
elif (choice == 10):
os.system("python molesFromGrams.py")
elif (choice == 11):
os.system("python gramsFromAtoms.py")
elif (choice == 12):
os.system("python gramsFromMoles.py")
elif (choice == 13):
os.system("python molesNeeded.py")
keepGoing = input("Would you like to run another program? (Y or N)\n-->")
if (keepGoing.upper() == "Y"):
print(options)
continue
elif (keepGoing.upper() == "N"):
break
else:
break