@DomminicMayer/

VacantDefinitiveProblem

Python

No description

fork
loading
Files
  • main.py
main.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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
import re

m = {"H": 1.0079, "He": 4.0026, "Li": 6.941, "Be": 9.0122,
     "B": 10.811, "C": 12.011, "N": 14.007, "O": 15.999, "F": 18.998,
     "Ne": 20.180, "Na": 22.990, "Mg": 24.305, "Al": 26.982,
     "Si": 28.086, "P": 30.974, "S": 32.065, "Cl": 35.453,
     "Ar": 39.948, "K": 39.098, "Ca": 40.078, "Sc": 44.956,
     "Ti": 47.867, "V": 50.942, "Cr": 51.996, "Mn": 54.938,
     "Fe": 55.845, "Co": 58.933, "Ni": 58.693, "Cu": 63.546,
     "Zn": 65.39, "Ga": 69.723, "Ge": 72.61, "As": 74.922,
     "Se":78.96, "Br": 79.904, "Kr": 83.80, "Rb": 85.468, "Sr": 87.62,
     "Y": 88.906, "Zr": 91.224, "Nb": 92.906, "Mo": 95.94,
     "Tc": 97.61, "Ru": 101.07, "Rh": 102.91, "Pd": 106.42,
     "Ag": 107.87, "Cd": 112.41, "In": 114.82, "Sn": 118.71,
     "Sb": 121.76, "Te": 127.60, "I": 126.90, "Xe": 131.29,
     "Cs": 132.91, "Ba": 137.33, "La": 138.91, "Ce": 140.12,
     "Pr": 140.91, "Nd": 144.24, "Pm": 145.0, "Sm": 150.36, "Eu": 151.96,
     "Gd": 157.25, "Tb": 158.93, "Dy": 162.50, "Ho": 164.93, "Er": 167.26,
     "Tm": 168.93, "Yb": 173.04, "Lu": 174.97, "Hf": 178.49, "Ta": 180.95,
     "W": 183.84, "Re": 186.21, "Os": 190.23, "Ir": 192.22, "Pt": 196.08,
     "Au": 196.08, "Hg": 200.59, "Tl": 204.38, "Pb": 207.2, "Bi": 208.98,
     "Po": 209.0, "At": 210.0, "Rn": 222.0, "Fr": 223.0, "Ra": 226.0,
     "Ac": 227.0, "Th": 232.04, "Pa": 231.04, "U": 238.03, "Np": 237.0,
     "Pu": 244.0, "Am": 243.0, "Cm": 247.0, "Bk": 247.0, "Cf": 251.0, "Es": 252.0,
     "Fm": 257.0, "Md": 258.0, "No": 259.0, "Lr": 262.0, "Rf": 261.0, "Db": 262.0,
     "Sg": 266.0, "Bh": 264.0, "Hs": 269.0, "Mt": 268.0}
     
#print instructions for use 
print('''
WELCOME TO ATOMIC CALCULATOR

There are several interactions with this calculator. 

To enter an element, always use proper capitalization when typing the appropriate atomic symbol. 

When entering compounds, spaces are used to seperate coefficients, atomic symbols, and subscripts. 

Examples of correct compound entry:
2 He 2 C 1
(Mole Element Coefficient Element Coefficient)

Note that if there is only one atom of an element in the compound, you must enter a 1 as a subscript. 

'''
'''
def cfind():
  comp=input('ele ')
  comp=comp.split(' ')
  print ('1: '+str(comp))
  coef=comp[0]
  del comp[0]
  print (comp)
  v=len(comp)
  print(coef)
  for x in range(0,v):
    inputdictionary = m[inputdictionary[x]]
    print (inputdictionary)
def cfind():
  comp=input('ele ')
  comp=comp.split(' ')
  print ('1: '+str(comp))

  coef=comp[0]
  del comp[0]

  print (comp)
  v=len(comp)
  comp.split(",")
  print (comp)
'''
#CALCULATIONS

#Calculate AMU/MM
def calamu(ele,coef):
    #save AMU
    amu = m[ele]
    mol = amu*int(coef) #save mm
    return mol

#Calculate Volume
def calvol(mol):
  vol=mol*22.4
  return vol

#Calculate unkown mols
def calmol(ele,mas):
  ele1=m[ele]
  mol=mas/ele1
  return mol

#Return atomic mass
def findamu(ele):
  amu=m[ele]
  return amu


###
win = tk.Tk()
win.title(" GUI ")
win.mainloop()
###


#What do you want done?
#define as cal(culation)

cal = input('''What do you want done?
  1= Mass of element x moles in grams
  2= Mols of element/compound based on mass
  3= Total molar mass of compound
  4= Volume of an element/compound
  5= Find AMU of element

''')

#1 Mass of element with moles

if cal == '1':
  ele=input('Okay, please enter the element: ')
  coef=int(input('What is the coefficient? '))
  mas=str(m[ele]*coef)
  print (mas+'g')



  
#2 find mols of ele/compound based on grams

if cal == '2':
  ele = input('Okay, what element are you trying to find the mols of? ')
  mas = input('What is the total mass in grams? ')
  mol = calmol(ele,float(mas))
  print ('There must be '+str(mol)+' mols of '+(ele))

  #asks whether to convert to other forms

  cont=input('Would you like to convert to another form? Y/N ')
  if cont == 'Y' or 'y':
    cal=input('''Okay, What would you like to do?
    1= Calculate the volume (gas)
    2= Exit
    ''')
    if cal == '1':
      vol=calvol(mol)
      print(str('In STP (standard temperature and pressure) '+str(mas)+'g of '+str(ele)+' fills a volume of '+str(vol)))

#3 requires splicing for compound




#4, calculate volume with mass

if cal == '4':

  cal4 = input ('''Please indicate how you would like to calculate volume:
  1= With element and coefficient
  2= With a known mass in grams
  3= With known mols

  ''')
  
  if cal4 == '1':
    ele=float(m[input('Atomic symbol: ')])
    coef= float(input('What is the coefficient? '))
    var=ele*coef
    print (str(calvol(var)))

  if cal4 == '2':
    mas=float(input('What is the mass(in grams)? '))
    out=mas*22.4
    print(str(out)+'L')

  if cal4 == '3':
    mol=float(input('How many mols of gas? '))
    out=mol*22.4
    print(str(out)+'L')
#5

if cal == '5':
  print(str(m[input('What is the atomic symbol of the element? ')])+' amu')