0% found this document useful (0 votes)
22 views16 pages

Computer Project Body

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views16 pages

Computer Project Body

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Preface

Welcome to the world of Python programming! This


project has been crafted with the aim of introducing
Class 12 students to the fundamentals of programming
using the versatile and beginnerfriendly Python
language. As you embark on this journey, you will delve
into the core concepts of coding, problem-solving, and
algorithmic thinking. Python’s simplicity and readability
make it an ideal choice for those stepping into the
realm of programming for the first time. Through
hands-on exercises and practical examples, this project
will not only teach you the syntax of Python but also
instil a deeper understanding of how to tackle real-
world problems with code. Whether you are aspiring to
become a software developer, data scientist, or simply
want to enhance your problem-solving skills, this
project will lay a solid foundation for your journey
ahead. Embrace the challenges, celebrate the victories,
and enjoy the process of bringing your ideas to life
through the power of Python programming.
About the project
In this Python programming project, I have developed a
comprehensive Periodic Elements Record Management
System designed to efficiently manage and organize
information about different periodic elements along
with their physical properties and year in which they
are discovered. The system incorporates a user-friendly
interface allowing users to input, update, and retrieve
data effortlessly. Leveraging Python's versatility, the
program employs data structures to store details such
as element name, atomic number, element’s symbol,
and other physical properties. The project utilizes file
handling to store and retrieve data persistently,
ensuring that information remains intact even after the
program is closed. Through this endeavour, I aimed to
enhance my proficiency in Python programming while
creating a practical tool that could be employed in real-
world scenarios.
Source Code
def add():

import pickle

s={}

f=open('element.dat','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)

pickle.dump(s,f)

ans= input("Do you want to add more records(y/n)")

f.close()

def display():

import pickle

s={}

f=open('element.dat','rb')

print('\n')

try:

while True:

s=pickle.load(f)

print(s)

except EOFError:

f.close()

def search():

import pickle

s={}

found='f'

f=open('element.dat','rb')
ano=int(input("Enter atomic number of the element to be searched:"))

print('\n')

try:

while True:

s=pickle.load(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')

f.close()

def update():

import pickle

s={}

found="f"

f=open('element.dat','rb+')

print('\n')

ano= int(input("Enter atomic number of the element to be updated:"))

try:
while True:

pos=f.tell()

s=pickle.load(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)

f.seek(pos)

pickle.dump(s,f)

break

except EOFError:

if found=='t':

print("found")

print('\n')

else:

print("not found")

print('\n')

f.close()

def delete():

import pickle

import os

s={}

found='f'

f=open('element.dat','rb+')

f1=open('element1.dat','wb+')

print('\n')

ano=int(input("Enter atomic number to be deleted:"))

try:

while True:
s=pickle.load(f)

if s['Atomic number of the element']!=ano:

pickle.dump(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')

f.close()

f1.close()

os.remove('element.dat')

os.rename('element1.dat','element.dat')

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
Output
Output 1
Elements record /n

1. To add an element's record

2. To display th records

3. To search for a record

4. To update a record

5. To delete a record

6. To exit

Enter your choice 1-6: 1

Add new record

Enter element's name: Sodium

Enter elemnets symbol: Na

Enter element's block and group: s-1

Enter atomic number of the element: 11

Enter atomic weight of the element: 22.989

Enter density(g/ml) of the element: 0.971

Enter atomic radius of the element: 186

Enter melting point(c) of the element: 97.8

Enter boiling point of the element: 552.9

Enter year of discovery of the element: 1807

{'Name of the element': 'Sodium', 'Symbol of the element': 'Na', 'Block and group of the
element': 552.9, 'Atomic number of the element': 11, 'Atomic weight of the element': 22.989,
'Density of the element': 0.971, 'Atomic radius of the element': 186.0, 'Melting point of the
element': 97.8, 'Boiling point of the element': 552.9, 'Year of discovery of the element': 1807}
Output 2
Do you want to add more records(y/n) n

Elements record /n

1. To add an element's record

2. To display th records

3. To search for a record

4. To update a record

5. To delete a record

6. To exit

Enter your choice 1-6: 3

Enter atomic number of the element to be searched: 11

{'Name of the element': 'Sodium', 'Symbol of the element': 'Na', 'Block and group of the
element': 552.9, 'Atomic number of the element': 11, 'Atomic weight of the element': 22.989,
'Density of the element': 0.971, 'Atomic radius of the element': 186.0, 'Melting point of the
element': 97.8, 'Boiling point of the element': 552.9, 'Year of discovery of the element': 1807}

found
Output 3
Elements record /n

1. To add an element's record

2. To display th records

3. To search for a record

4. To update a record

5. To delete a record

6. To exit

Enter your choice 1-6:4

Enter atomic number of the element to be updated:11

{'Name of the element': 'Sodium', 'Symbol of the element': 'Na', 'Block and group of the
element': 552.9, 'Atomic number of the element': 11, 'Atomic weight of the element': 22.989,
'Density of the element': 0.971, 'Atomic radius of the element': 186.0, 'Melting point of the
element': 97.8, 'Boiling point of the element': 552.9, 'Year of discovery of the element': 1807}

Enter element's name: Aluminium

Enter element’s symbol: Al

Enter element's block and group: p-13

Enter atomic number of the element: 13

Enter atomic weight of the element: 26.982

Enter density(g/ml) of the element: 2.702

Enter atomic radius of the element: 143

Enter melting point(c) of the element: 660.37

Enter boiling point of the element: 2467.0


Enter year of discovery of the element: 1825

{'Name of the element': 'Aluminium', 'Symbol of the element': 'Al', 'Block and group of the
element': 2467.0, 'Atomic number of the element': 13, 'Atomic weight of the element':
26.982, 'Density of the element': 2.702, 'Atomic radius of the element': 143.0, 'Melting point
of the element': 660.37, 'Boiling point of the element': 2467.0, 'Year of discovery of the
element': 1825}
Output 4
Elements record /n

1. To add an element's record

2. To display th records

3. To search for a record

4. To update a record

5. To delete a record

6. To exit

Enter your choice 1-6:5

Enter atomic number to be deleted: 13

found and deleted


References
1. I have taken the help of my text book (Computer
science with Python) by Sumita Arora.
2. I have taken suggestions from my friends related to
the project.
3. I have taken help from my subject teacher, Mr.
Ghazanfer Ali.
4. I have taken help from Google and Chat gpt to
complete this project.
Limitations
No project is ever perfect, there is always scope of
improvement. This program too
Have certain limitations:
• The project can be updated to have more attributes.
• The project is further extensible.
• The existing system only provides a text-based
interface, which is not as userfriendly as a Graphical
user interface.
• The output for display is also a bit messy and less
user-friendly.

You might also like