-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelements1.py
More file actions
35 lines (28 loc) · 1.32 KB
/
elements1.py
File metadata and controls
35 lines (28 loc) · 1.32 KB
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
periodic_table = {
'H': {'name': 'Hydrogen', 'atomic_number': 1, 'atomic_mass': 1.008, 'group': 'Nonmetal'},
'He': {'name': 'Helium', 'atomic_number': 2, 'atomic_mass': 4.0026, 'group': 'Noble Gas'},
'Li': {'name': 'Lithium', 'atomic_number': 3, 'atomic_mass': 6.94, 'group': 'Alkali Metal'},
'Be': {'name': 'Beryllium', 'atomic_number': 4, 'atomic_mass': 9.0122, 'group': 'Alkaline Earth Metal'},
# Add more elements here...
}
def display_periodic_table():
print("Periodic Table")
print("{:<4} {:<12} {:<14} {:<10}".format("Symbol", "Name", "Atomic Number", "Atomic Mass"))
print("-" * 44)
for symbol, element in periodic_table.items():
name = element['name']
atomic_number = element['atomic_number']
atomic_mass = element['atomic_mass']
print("{:<4} {:<12} {:<14} {:<10}".format(symbol, name, atomic_number, atomic_mass))
print()
# Display the periodic table
display_periodic_table()
# Remove an element from the periodic table
symbol_to_remove = 'Be'
if symbol_to_remove in periodic_table:
del periodic_table[symbol_to_remove]
print(f"Removed {symbol_to_remove} from the periodic table.")
else:
print(f"{symbol_to_remove} does not exist in the periodic table.")
# Display the updated periodic table
display_periodic_table()