CS PERIODIC TABLE Project OG
CS PERIODIC TABLE Project OG
----------------------------------- -------------------------------
-----------------------------------
TECHNICAL SPECIFICATIONS
Software used:
1. Python version 2.7.18
2. MySQL command line client
import mysql.connector
mydb=mysql.connector.connect(host='localhost',user='root',
Password='********',database='project')
mycursor=mydb.cursor()
def Display():
mycursor.execute('select * from elements')
rows=mycursor.fetchall()
print('AtomicNo\t\tElement')
for i in rows:
print(i[0],i[1],sep='\t\t\t\t')
def Mass():
name=input('enter Name to find mass')
query="select Mass from Elements WHERE Element = '%s'" % (name)
mycursor.execute(query)
myrecord=mycursor.fetchone()
if myrecord !=None:
for i in myrecord:
print(i)
else:
print('no such element exists')
def Details():
name=input('enter Name to find the details')
query="select * from Elements WHERE Element = '%s'" % (name)
mycursor.execute(query)
myrecord=mycursor.fetchone()
if myrecord !=None:
print('AtomicNo:',myrecord[0])
print('Element:',myrecord[1])
print('Symbol:',myrecord[2])
print('GroupNo:',myrecord[3])
print('PeriodNo:',myrecord[4])
print('Mass:',myrecord[5])
print('Phase at STP:',myrecord[6])
print('Natural or Artificial:',myrecord[7])
print('Valency:',myrecord[8])
else:
print('no such element exists')
def Compounds():
x=0
xn=0
y=0
yn=0
a=input('enter 1st element (symbol) between 1 to 20')
query1="select Valency from Elements WHERE Symbol = '%s'" % (a)
b=input('enter 2nd element (symbol) between 1 to 20')
query2="select Valency from Elements WHERE Symbol = '%s'" % (b)
mycursor.execute(query1)
myrecord=mycursor.fetchone()
if myrecord !=None:
for i in myrecord:
x+=i
mycursor.execute(query2)
myrecord=mycursor.fetchone()
if myrecord !=None:
for i in myrecord:
y+=i
print('Valency of',a,'=',x,' Valency of',b,'=',y)
if x==0 or y==0:
print('No compound is formed')
elif x > y:
smaller = y
else:
smaller = x
if x!=0 and y!=0:
for i in range(1, smaller+1):
if((x % i == 0) and (y % i == 0)):
hcf = i
if hcf in range(0,10):
xn=int(x//hcf)
yn=int(y//hcf)
if yn==1:
if xn==1:
print(a,b,sep='')
else:
print(a,b,xn,sep='')
elif xn==1:
print(a,yn,b,sep='')
else:
print(a,yn,b,xn,sep='')
while True:
opt=int(input('1.Display 2.Mass 3.Details 4.Compounds 5.Exit'))
if opt==1:
Display()
elif opt==2:
Mass()
elif opt==3:
Details()
elif opt==4:
Compounds()
elif opt==5:
break
else:
print('Invalid Code')
OUTPUT
SCOPE FOR IMPROVEMENT