-
Notifications
You must be signed in to change notification settings - Fork 0
/
sandbox.py
40 lines (32 loc) · 1.23 KB
/
sandbox.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
# defines an atom class
class Atom:
def __init__(self, name, symbol, atomic_number, mass, valence_electrons, configuration, oxidation_state, radius, electronegativity):
self.name = name
self.symbol = symbol
self.atomic_number = atomic_number
self.mass = mass
self.valence_electrons = valence_electrons
self.configuration = configuration
self.oxidation_state = oxidation_state
self.radius = radius
self.electronegativity = electronegativity
def __str__(self):
return f"{self.name} ({self.symbol})"
def bond_valence(self):
return self.valence_electrons - self.oxidation_state
def orbitals(self):
return self.configuration.split()
def config_string(self):
return f"{self.configuration} ({self.oxidation_state})"
# main
if __name__ == "__main__":
hydrogen = Atom("Hydrogen", "H", 1, 1.00794, 1, "1s1", 0, 0.31, 2.2)
print(hydrogen)
print(hydrogen.bond_valence())
print(hydrogen.orbitals())
print(hydrogen.config_string())
carbon = Atom("Carbon", "C", 6, 12.0107, 4, "2s2 2p2", 2, 0.77, 2.55)
print(carbon)
print(carbon.bond_valence())
print(carbon.orbitals())
print(carbon.config_string())