I wanna make a PYTHON Program That Prints Out All Of The Elements Of The Periodic Table With A Certain Group. This is my code so far.
print("Enter the symbol or name of an element, or the group (Transition Metal, Noble Gases) it belongs to: ")
name = str(input())
data = [
{
"symbol": "Au",
"element": "Gold",
"group": "Transition Metal",
"weight": "196.96657u"
},
{
"symbol": "Fe",
"element": "Iron",
"group": "Transition Metal",
"weight": "55.845u"
},
{
"symbol": "Cu",
"element": "Copper",
"group": "Transition Metal",
"weight": "63.546u"
},
{
"symbol": "Zn",
"element": "Zinc",
"group": "Transition Metal",
"weight": "65.38u"
},
{
"symbol": "Ti",
"element": "Titanium",
"group": "Transition Metal",
"weight": "47.867u"
},
{
"symbol": "He",
"element": "Helium",
"group": "Noble Gases",
"weight": "4.002602u"
},
{
"symbol": "Ar",
"element": "Argon",
"group": "Noble Gases",
"weight": "39.948u"
},
{
"symbol": "Co",
"element": "Cobalt",
"group": "Transition Metal",
"weight": "58.933195u"
},
{
"symbol": "Kr",
"element": "Krypton",
"group": "Noble Gases",
"weight": "83.798u"
},
{
"symbol": "Ne",
"element": "Neom",
"group": "Noble Gases",
"weight": "20.1797u"
},
{
"symbol": "Rn",
"element": "Radon",
"group": "Noble Gases",
"weight": "222u"
},
{
"symbol": "Xe",
"element": "Xenon",
"group": "Noble Gases",
"weight": "131.293u"
}
]
for i in data:
if i['symbol'].lower() == name.lower():
print("Element: ", i['element'], "(", i['symbol'], ")")
print("Atomic Weight:", i['weight'])
print("Group:", i['group'])
break
for i in data:
if i['element'].lower() == name.lower():
print("Element: ", i['element'], "(", i['symbol'], ")")
print("Atomic Weight:", i['weight'])
print("Group:", i['group'])
break
source https://stackoverflow.com/questions/73758525/look-through-json-and-print-all-values-with-a-certain-value
Comments
Post a Comment