def add():
import pickle
s={}
f=open('[Link]','wb')
ans='y'
while ans== 'y':
n= input("Enter element's name:")
c= input("Enter elemnets symbol:")
b= input("Enter element's block and group:")
a= int(input("Enter atomic number of the element:"))
w= float(input("Enter atomic weight of the element:"))
d= float(input("Enter density(g/ml) of the element:"))
r= float(input("Enter atomic radius of the element:"))
m= float(input("Enter melting point(c) of the element:"))
b= float(input("Enter boiling point of the element:"))
y= int(input("Enter year of discovery of the element:"))
s['Name of the element']=n
s['Symbol of the element']=c
s['Block and group of the element']=b
s['Atomic number of the element']=a
s['Atomic weight of the element']=w
s['Density of the element']=d
s['Atomic radius of the element']=r
s['Melting point of the element']=m
s['Boiling point of the element']=b
s['Year of discovery of the element']=y
print(s)
[Link](s,f)
ans= input("Do you want to add more records(y/n)")
[Link]()
def display():
import pickle
s={}
f=open('[Link]','rb')
print('\n')
try:
while True:
s=[Link](f)
print(s)
except EOFError:
[Link]()
def search():
import pickle
s={}
found='f'
f=open('[Link]','rb')
ano=int(input("Enter atomic number of the element to be searched:"))
print('\n')
try:
while True:
s=[Link](f)
if s['Atomic number of the element']==ano:
found='t'
print(s)
except EOFError:
if found=='t':
print("found")
print('\n')
else:
print('not found')
print('\n')
[Link]()
def update():
import pickle
s={}
found="f"
f=open('[Link]','rb+')
print('\n')
ano= int(input("Enter atomic number of the element to be updated:"))
try:
while True:
pos=[Link]()
s=[Link](f)
if s['Atomic number of the element']==ano:
found='t'
print(s)
n= input("Enter element's name:")
c= input("Enter elemnets symbol:")
b= input("Enter element's block and group:")
a= int(input("Enter atomic number of the element:"))
w= float(input("Enter atomic weight of the element:"))
d= float(input("Enter density(g/ml) of the element:"))
r= float(input("Enter atomic radius of the element:"))
m= float(input("Enter melting point(c) of the element:"))
b= float(input("Enter boiling point of the element:"))
y= int(input("Enter year of discovery of the element:"))
s['Name of the element']=n
s['Symbol of the element']=c
s['Block and group of the element']=b
s['Atomic number of the element']=a
s['Atomic weight of the element']=w
s['Density of the element']=d
s['Atomic radius of the element']=r
s['Melting point of the element']=m
s['Boiling point of the element']=b
s['Year of discovery of the element']=y
print(s)
[Link](pos)
[Link](s,f)
break
except EOFError:
if found=='t':
print("found")
print('\n')
else:
print("not found")
print('\n')
[Link]()
def delete():
import pickle
import os
s={}
found='f'
f=open('[Link]','rb+')
f1=open('[Link]','wb+')
print('\n')
ano=int(input("Enter atomic number to be deleted:"))
try:
while True:
s=[Link](f)
if s['Atomic number of the element']!=ano:
[Link](s,f1)
else:
found='t'
except EOFError:
if found=='t':
print("found and deleted")
print('\n')
else:
print("Record not found and hence can't be deleted")
print('\n')
[Link]()
[Link]()
[Link]('[Link]')
[Link]('[Link]','[Link]')
ch=1
while ch:
print("Elements record /n")
print("1. To add an element's record")
print("2. To display the records")
print("3. To search for a record")
print("4. To update a record")
print("5. To delete a record")
print("6. To exit")
ch= int(input("Enter your choice 1-6:"))
if ch==1:
print("Add new record")
add()
elif ch==2:
print("Display all records")
display()
elif ch==3:
search()
elif ch==4:
update()
elif ch==5:
delete()
else:
ch==6
print("To exit \n")
break