Professional Documents
Culture Documents
BHAGWANPUR
COMPUTER SCIENCE(083)
TOPIC PAGE.NO
1.ACKNOWLEDGEMENT………………4
2.DIGITAL INDIA PROGRAMME…………5
3.HISTORY OF PYTHON…………………14
2.PREFACE………………………………18
3.MODULES USED…………… 20
4.USER DEFINED FUNCTION…….21
5.PROJECT CODE …………………22
6.SAMPLE OUTPUT……………………36
7.LIMITATION……………………………46
8.BIBLIOGRAPHY…………………………47
I have made sincere effort to make the project more meaningful, complete,
compact and comprehensive. I also express my sincere thanks to my family
members & friends, especially my parents, who have been perennial sources
of inspiration.
Anushka Jaiswal
A Digital India Year would make sure that each and every
aspect of the programme is pushed to show results on the
ground and not go into hibernation after one week of
enthusiasm.
Readability counts.
Python version 1.0 was released in January 1994. The major new
features included in this release were the functional programming
tools lambda, map, filter and reduce, which Guido Van Rossum
never liked.
Six and a half years later in October 2000, Python 2.0 was
introduced. This release included list comprehensions, a full garbage
collector and it was supporting unicode.
Anushka Jaiswal
1)PYMYSQL:
2) SYS:
mycursor.execute(query.format(pno,pname,gname,disname,d
oa,dod,doctname))
resp=input("do you want to save record(Y/N):-")
print(str(row["pno"]).ljust(8),str(row["pname"]).ljust(25),str(row
["gname"]).ljust(25),str(row["disname"]).ljust(25),str(row["doa"
print(str(row["pno"]).ljust(8),str(row["pname"]).ljust(25),str(row
["gname"]).ljust(25),str(row["disname"]).ljust(25),str(row["doa"
]).ljust(15),str(row["dod"]).ljust(15),str(row["doctname"]).ljust(2
5))
ctr+=1
if ctr%30==0:
input('press any key to see more.....')
print("patient's
number".ljust(8),"name".ljust(25),"guardian".ljust(25),"disease"
.ljust(25),"doa".ljust(15),"dod".ljust(15),"doctor".ljust(15))
print(132*'=')
#code for displaying patient disease wise*********
def qdiswisepat():
mycursor=conn.cursor()
dname=input("enter disease name:--")
query="select*from pat where lower(disname like '%{}%')"
mycursor.execute(query.format(dname))
count=mycursor.rowcount
if count==0:
print ("no patients found!")
else:
print("patient details are:-")
rows=mycursor.fetchall()
print(str(row["pno"]).ljust(8),str(row["pname"]).ljust(25),str(row
["gname"]).ljust(25),str(row["disname"]).ljust(25),str(row["doa"
]).ljust(15),str(row["dod"]).ljust(15),str(row["doctname"]).ljust(2
5))
ctr+=1
if ctr%30==0:
input('press any key to see more.....')
print("patient's
number".ljust(8),"name".ljust(25),"guardian".ljust(25),"disease"
.ljust(25),"doa".ljust(15),"dod".ljust(15),"doctor".ljust(15))
print(132*'=')
#code for displaying patient date of discharge wise*******
def qdodwisepat():
mycursor=conn.cursor()
dod=input("enter patient date of discharge(yyyy-mm-dd):-
-")
query="select*from pat where dod='{}'"
mycursor.execute(query.format(dod))
count=mycursor.rowcount
if count==0:
print ("no patients found!")
Board Roll No: 23726918 Page:27
else:
print("patient details are:-")
rows=mycursor.fetchall()
print("patient's
number".ljust(8),"name".ljust(25),"guardian".ljust(25),"disease"
.ljust(25),"doa".ljust(15),"dod".ljust(15),"doctor".ljust(15))
print(132*'=')
ctr=1
for row in rows:
print(str(row["pno"]).ljust(8),str(row["pname"]).ljust(25),str(row
["gname"]).ljust(25),str(row["disname"]).ljust(25),str(row["doa"
]).ljust(15),str(row["dod"]).ljust(15),str(row["doctname"]).ljust(2
5))
ctr+=1
if ctr%30==0:
input('press any key to see more.....')
print("patient's
number".ljust(8),"name".ljust(25),"guardian".ljust(25),"disease"
.ljust(25),"doa".ljust(15),"dod".ljust(15),"doctor".ljust(15))
print(132*'=')
#code for displaying patients doctor wise**********
def qdoctwisepat():
mycursor=conn.cursor()
doname=input("enter doctor's name:--")
query="select*from pat where lower(doctname like
'%{}%')"
mycursor.execute(query.format(doname))
Board Roll No: 23726918 Page:28
count=mycursor.rowcount
if count==0:
print ("no patients found!")
else:
print("patient details are:-")
rows=mycursor.fetchall()
print("patient's
number".ljust(8),"name".ljust(25),"guardian".ljust(25),"disease"
.ljust(25),"doa".ljust(15),"dod".ljust(15),"doctor".ljust(15))
print(132*'=')
ctr=1
for row in rows:
print(str(row["pno"]).ljust(8),str(row["pname"]).ljust(25),str(row
["gname"]).ljust(25),str(row["disname"]).ljust(25),str(row["doa"
]).ljust(15),str(row["dod"]).ljust(15),str(row["doctname"]).ljust(2
5))
ctr+=1
if ctr%30==0:
input('press any key to see more.....')
print("patient's
number".ljust(8),"name".ljust(25),"guardian".ljust(25),"disease"
.ljust(25),"doa".ljust(15),"dod".ljust(15),"doctor".ljust(15))
print(132*'=')
#code for displaying patient number wise***********
def qnumwisepat():
mycursor=conn.cursor()
pnum=int(input("enter patient's number:--"))
Board Roll No: 23726918 Page:29
query="select*from pat where pno={}"
mycursor.execute(query.format(pnum))
count=mycursor.rowcount
if count==0:
print ("no patients found!")
else:
print("patient details are:-")
rows=mycursor.fetchall()
print("patient's
number".ljust(8),"name".ljust(25),"guardian".ljust(25),"disease"
.ljust(25),"doa".ljust(15),"dod".ljust(15),"doctor".ljust(15))
print(132*'=')
ctr=1
for row in rows:
print(str(row["pno"]).ljust(8),str(row["pname"]).ljust(25),str(row
["gname"]).ljust(25),str(row["disname"]).ljust(25),str(row["doa"
]).ljust(15),str(row["dod"]).ljust(15),str(row["doctname"]).ljust(2
5))
ctr+=1
if ctr%30==0:
input('press any key to see more.....')
print("patient's
number".ljust(8),"name".ljust(25),"guardian".ljust(25),"disease"
.ljust(25),"doa".ljust(15),"dod".ljust(15),"doctor".ljust(15))
print(132*'=')
#code for modifying patient detail************
def modpat():
Board Roll No: 23726918 Page:30
mycursor=conn.cursor()
pnum=int(input("enter patient's number:--"))
query="select*from pat where pno={}"
mycursor.execute(query.format(pnum))
count=mycursor.rowcount
if count==0:
print("patient number",pnum,'not found!')
else:
print('patient number',pnum,'has following details:-')
rows=mycursor.fetchall()
for row in rows:
print("patient's number:-",row["pno"])
print("patient's name:-",row["pname"])
print("guardian's name:-",row["gname"])
print("disease's name:-",row["disname"])
print("date of admit:-",row["doa"])
print("date of discharge:-",row["dod"])
print("docter's name:-",row["doctname"])
c=input('do you want to change (y/n)?')
if c in ['y','Y']:
pn=input("enter patient's name:--")
gn=input("enter guardian's name:--")
dn=input("enter disease name:--")
da=input("enter date of admit:-")
dd=input("enter date of discharge:-")
don=input("enter doctor's name:-")
elif ch1==2:
qnamewisepat()
elif ch1 == 3:
qdoawisepat()
elif ch1 == 4:
qdodwisepat()
elif ch1==5:
qdoctwisepat()
elif ch1==6:
qnumwisepat()
elif ch1==7:
qdiswisepat()
Board Roll No: 23726918 Page:34
elif ch1==8:
mainmenu()
else:
print("wrong choice!!, backto mainmenu")
mainmenu()
elif ch==3:
modpat()
elif ch==4:
delpat()
elif ch==5:
status=input('do you really want to exit (Y/N)...? ')
if status in ['y','Y']:
sys.exit()
else:
pass
else:
print ('wrong choice! try again!')
mainmenu()
#main program
import pymysql as sql
import sys
conn=
sql.connect(user='root',host='localhost',password='sunbeam'
)
Board Roll No: 23726918 Page:35
mycursor=conn.cursor()
choice=input('do you want to create environment for patient
management software(y/n)?')
if choice in ['y','Y']:
mycursor.execute('create database if not exists patient')
mycursor.execute('use patient')
mycursor.execute('create table if not exists pat(pno
int(8)primary key,pname varchar(25), gname varchar(25),
disname varchar(25), doa date, dod date, doctname
varchar(25))')
else:
print('exitting....')
conn=sql.connect(user='root',host='localhost',
password='sunbeam',database='patient',cursorclass=sql.curs
ors.Dictcursor)
while True:
mainmenu()