Member-only story

Python Code for Periodic Table

Python Coding
1 min readNov 1, 2024

--

pip install periodictable
import periodictable

Atomic_No = int(input("Enter Atomic No :"))

element = periodictable.elements[Atomic_No]
print('Name:', element.name)
print('Symbol:', element.symbol)
print('Atomic mass:', element.mass)
print('Density:', element.density)

#source code --> clcoding.com
Name: zinc
Symbol: Zn
Atomic mass: 65.409
Density: 7.133

This code snippet uses the periodictable library to retrieve information about a chemical element based on its atomic number.

Explanation of Each Line

import periodictable

  • This line imports the periodictable library, which provides data on all elements in the periodic table, including properties like atomic mass, density, and symbol.

Atomic_No = int(input("Enter Atomic No :"))

  • This line takes user input for an atomic number, converts it to an integer, and stores it in the variable Atomic_No.

element = periodictable.elements[Atomic_No]

  • Using the atomic number provided, this line retrieves the corresponding element from periodictable.elements and assigns it to the variable element.

print('Name:', element.name)

  • Prints the name of the element (e.g…

--

--

Python Coding
Python Coding

Written by Python Coding

Learn python tips and tricks with code I Share your knowledge with us to help society. Python Quiz: https://www.clcoding.com/p/quiz-questions.html

No responses yet