SlideShare a Scribd company logo
1 of 23
Download to read offline
INVESTIGATORY PROJECT
KENDRIYA VIDHYALAYA JANAKPURI
ACADEMIC YEAR :- 2022-2023
STUDENT DETAIL
ROLL NO. :- 26633855
NAME :- ARYAN NAGLOT
CLASS :- XII-B
SUBJECT AND CODE :- COMPUTER SCIENCE
CERTIFICATE
NAME :- ARYAN NAGLOT
CLASS :- XII-B
ROLL NO. :- 26633855
This is certified to be he Bonafede work of the student in the
Kendriya Vidyalaya Janakpuri during the academic year
2022-2023.
___________________________
SUBJECT TEACHER SIGNATURE
_____________________
EXAMINER’S SIGNATURE
____________________
PRINCIPAL SIGNATURE
ACKNOWLEDGEMENT
I would like to thank my informatics practices teacher,
Sonia Sharma mam, whose valuable guidance has been the
ones that have helped me patch this project.
Her suggestions and instructions have served as the major
contributions towards the completion of the project.
Then I would like to thank my parents and friends who
have helped me with their valuable suggestions and
guidance that has been helpful in various phase of the
completion of this project.
~ ARYAN NAGLOT
QUESTION BASED PROGRAMS
1. WAP to show functionality of a basic calculator using functions.
def calculator(n1,n2,oper):
if oper=='+':
return n1+n2
elif oper=='-':
return n1-n2
elif oper=='*':
return n1*n2
elif oper=='/':
return n1/n2
elif oper=='//':
return n1//n2
elif oper=='%':
return n1%n2
else:
print('invalid operator..')
return 0
num1=float(input('enter first number:'))
num2=float(input('enter second number:'))
op=input('input operator among +,-,*,/,//,%:')
print(calculator(num1,num2,op))
****************************************************************************************************
2. Write a function in python which accept a number from user to return True, if the number is a prime
number else return False. Use this function to print all prime numbers from 1 to 100.
def checkPrime(n):
for i in range (2, n):
if n%i==0:
return False
else:
return True
l=[]
for i in range(1,101):
ans=checkPrime(i)
if ans==True:
l.append(i)
print('Prime numbers between 1 to 100=',l)
****************************************************************************************************
3. Write a function in python which accept a list of marks of students and return the minimum mark,
maximum mark and the average marks. Use the same function to test.
def checkList(l):
return min(l),max(l),(sum(l)/len(l))
marks=eval(input('enter the marks of students:'))
minList,maxList,avgList=checkList(marks)
print('MAXIMUM MARKS:',maxList)
print('MINIMUM MARKS:',minList)
print('AVERAGE MARKS:',avgList)
****************************************************************************************************
4. WAP to read a text file “myfile.txt” line by line and display each word separated by a #.
f=open(r'C:UsersComp_Lab_IIDesktopmyfile.txt')
def show():
try:
while True:
data=f.readline()
data=data.split()
for i in data:
print(i,'#',end='')
except:
f.close()
show()
****************************************************************************************************
5. WAP to read a text file “myfile.txt” and display the number of vowels/ consonants/ uppercase/ lowercase
characters in the file.
def show():
f=open(r'C:UsersComp_Lab_IIDesktopmyfile.txt')
data=f.read()
vowal=0
cons=0
uper=0
low=0
vowalList=['A','E','I','O','U','a','e','i','o','u']
for i in data:
if i.isalpha()==True:
if i in vowalList:
vowal+=1
else:
cons+=1
if i.isupper():
uper+=1
else:
low+=1
print('number of vowels:',vowal)
print('number of consonants:',cons)
print('number of Capital letters:',uper)
print('number of small letters:',low)
show()
****************************************************************************************************
6. Remove all the lines that contain the character `a' in a file and write it to another file.
def copyData():
f=open(r'C:UsersComp_Lab_IIDesktopmyfile.txt')
f2=open(r'C:UsersComp_Lab_IIDesktopmyfile2.txt','w+')
data=f.readlines()
for line in data:
if 'A' not in line:
if 'a' not in line:
f2.write(line)
f2.flush()
f2.seek(0)
data2=f2.read()
print(data2)
f.close()
f2.close()
copyData()
OR
def copyData():
f=open(r'C:UsersComp_Lab_IIDesktopmyfile.txt')
f2=open(r'C:UsersComp_Lab_IIDesktopmyfile3.txt','w+')
data=f.readlines()
for line in data:
if 'A' not in line and 'a' not in line:
f2.write(line)
f2.flush()
f2.seek(0)
data2=f2.read()
print(data2)
f.close()
f2.close()
copyData()
****************************************************************************************************
7. Write a program to create a text file and print the lines starting with ‘T’ or ‘P’. (Both uppercase and
lowercase).
def printData():
f=open(r'C:UsersComp_Lab_IIDesktopmyfile.txt')
data=f.readlines()
for line in data:
L1=['t','T','P','p']
if line[0] in L1:
print(line)
f.close()
printData()
****************************************************************************************************
8. Read a text file to print the frequency of the word ‘He’ and ‘She’ found in the file.
def readHeShe():
file=open(r'C:UsersComp_Lab_IIDesktopmyfile.txt')
data=file.read()
cntHe=0
cntShe=0
data=data.split()
for i in data:
i=i.lower()
if i=='he':
cntHe+=1
elif i=='she':
cntShe+=1
else:
continue
print('Frequency of "He" in file=',cntHe)
print('Frequency of "She" in file=',cntShe)
readHeShe()
****************************************************************************************************
9. Create a binary file with name and roll number. Search for a given roll number and display the name, if not found
display appropriate message.
import pickle
file=open(r'D:myBinaryFile.bin','ab+')
def inputData():
ans='y'
while ans=='y':
data=eval(input('enter the name and roll number of student:'))
pickle.dump(data,file)
file.flush()
ans=input('want to enter more data? Press Y or N')
ans=ans.lower()
def searchData():
file.seek(0)
try:
found=False
rno=int(input('enter the roll number to search:'))
while True:
data=pickle.load(file)
if data['roll number']==rno:
found=True
nm=data['name']
print('ROLL NUMBER=',rno,' AND NAME=',data['name'])
except:
if found==True:
print('data found..')
else:
print('data not found..')
file.close()
inputData()
searchData()
****************************************************************************************************
10. Create a binary file with roll number, name and marks. Input a roll number and update the marks.
import pickle
file=open(r'D:myBinaryFile2.bin','wb+')
def inputData():
ans='y'
while ans=='y':
data=eval(input('enter the name, roll number and marks of student:'))
pickle.dump(data,file)
file.flush()
ans=input('want to enter more data? Press Y or N')
ans=ans.lower()
def updateMarks():
file.seek(0)
try:
rno=int(input('enter the roll number to search:'))
newMarks=int(input('enter new marks'))
while True:
pos=file.tell()
data=pickle.load(file)
if data['roll number']==rno:
data['marks']=newMarks
file.seek(pos)
pickle.dump(data,file)
file.flush()
print('ROLL NUMBER=',data['roll number'],' AND NEW MARKS=',data['marks'])
except:
file.close()
def show():
file=open(r'D:myBinaryFile2.bin','rb+')
try:
while True:
data=pickle.load(file)
print(data)
except:
file.close()
inputData()
updateMarks()
show()
****************************************************************************************************
11. Read a CSV file from hard disc and print all the details on the screen.
def readCSV():
file=open(r'D:saurav.csv',newline='n')
readerObj=csv.reader(file)
for i in readerObj:
print(i)
file.close()
readCSV()
****************************************************************************************************
12. Read a CSV file (containing item no, name, rate, QOH) from hard disc and print all the items whose rate is
between Rs 500 and Rs 1000.
def readCSV():
file=open(r'D:saurav2.csv',newline='n')
readerObj=csv.reader(file)
for i in readerObj:
if i[2].isalpha()==True:
continue
else:
if float(i[2])>=500 and float(i[2])<=1000:
print(i[1])
file.close()
readCSV()
****************************************************************************************************
13. Create a CSV file by entering user-id and password, read and search the password for given userid.
file=open(r'D:saurav3.csv','a+',newline='n')
def writeCSV():
writerObj=csv.writer(file)
writerObj.writerow(['user-id','password'])
ans='y'
while ans=='y':
uid=input('enter user id:')
pwd=input('enter password:')
writerObj.writerow([uid,pwd])
file.flush()
ans=input('want to add more info? y or n..')
ans=ans.lower()
print('data saved successfully..')
def search():
file.seek(0)
uid=input('enter the id to search:')
readerObj=csv.reader(file)
for i in readerObj:
if i[0]==uid:
print('password=',i[1])
writeCSV()
search()
file.close()
****************************************************************************************************
14. Write a random number generator that generates random numbers between 1 and 6 (simulates a dice).
Throw the two dices for 10 times and print their total.
def rolladice():
counter = 1
myList = []
while counter <= 10:
randomNumber = random.randint(1,6)
#print('value of 1 dice ',counter,' time=',randomNumber)
randomNumber2=random.randint(1,6)
#print('value of 2 dice ',counter,' time=',randomNumber2)
myList.append(randomNumber+randomNumber2)
counter = counter + 1
return myList
# Take user input here
print(rolladice())
****************************************************************************************************
15. WAP in Python to demonstrate linear search.
def LinearSearch():
list1=eval(input('enter the list of elements:'))
element=eval(input('enter the element to search:'))
found=0
for i in list1:
if i==element:
found=1
position=list1.index(i)+1
else:
continue
if found==1:
print('element found in ',position,' position')
else:
print('element not found..')
LinearSearch()
****************************************************************************************************
16. Write a Python program to implement a stack using a list data-structure.
status=[]
def Push_element(list1):
status.append(list1)
def Pop_element():
while len(status)>0:
print(status.pop())
else:
print('Stack Empty..')
for i in range(5):
list1=eval(input('enter the list:'))
Push_element(list1)
Pop_element()
****************************************************************************************************
17. WAP to pass an integer list as stack to a function and push only those elements in the stack which are divisible
by 7.
status=[]
def Push_element(list1):
for i in list1:
if i% 7==0:
status.append(i)
print(status)
list1=eval(input('enter the integer list:'))
Push_element(list1)
****************************************************************************************************
CSV TABLE PROGRAM
# CSV TABLES:
import pandas as pd
import matplotlib as pyplot
from datetime import date
print("Welcome to ABC Library")
def addNewMember():
mid=int(input('Enter member id :'))
m_name=input('Enter member name :')
phoneno=int(input('Enter phone number :'))
noofbooksissued=0
mdf=pd.read_csv('CLIBRARYexcelfilesmember.csv')
n=mdf['mid'].count()
mdf.at[n]=[mid,m_name,phoneno,noofbooksissued]
mdf.to_csv('CLIBRARYexcel filesmember.csv,'index=False)
print('New member added')
print(mdf)
def searchMember():
m_name=input('Enter member name:')
bdf=pd.read_csv('C:LIBRARYexcelfilesmember.csv')
df=bdf.loc[bdf['mname']--m_name]
if df.empty:
print('No member found with this name')
else:
print('Members details:')
print(df)
def deleteMember():
mid = float(input('Enter member id :'))
bdf=pd.read_csv('CLIBRARYexcelfilesmembers.csv')
bdf=bdf.drop(bdf[bdf['mid']==mid].index)
bdf.to_csv('C:LIBRARYexcel filesmember.csv',index=False)
print('Member deleted')
print(bdf)
def showMembers():
bdf=pd.read_csv('C:LIBRARYexcelfilesmember.csv')
print(bdf)
def addNewBook():
bookid=int(input('Enter a bok id:'))
title=input('Enter book title:')
author=input('Enter author of the book:')
publisher=input('Enter book publisher:')
edition=input('Enter edition of the book:')
cost=input('Enter cost of the book:')
category=input('Enter category of the book:')
bdf=pd.read_csv("C:LIBRARYexcelfilesbook.csv")
n=bdf['bookid'].count()
bdf.at[n]=[bookid,title,author,publisher,edition,cost,category]
bdf.to_csv(r"C:LIBRARYexcelfilesbook.csv",index=False)
print('Book added successfully')
print(bdf)
def searchBook():
title=input('Enter a book name : ')
bdf=pd.read_csv('C:LIBRARYexcelfilesbook.csv')
df=bdf.loc[bdf['title']==title]
if df.empty:
print('no book found with this code')
else:
print('Book details:')
print(df)
def deleteBook():
bookid=float(input('Enter book id :'))
bdf=pd.read_csv(r'C:LIBRARYexcel filesbook.csv')
bdf=bdf.drop(bdf[bdf['bookid']--bookid].index)
bdf.to_csv('C:LIBRARYexcelfilesbook.csv',index=False)
print("Book deleted")
print(bdf)
def showBooks():
bdf=pd.read_csv('C:LIBRARYexcelfilesbook.csv')
print(bdf)
def issueBooks():
book_name=input('Enter book name:')
bdf=pd.read_csv('C:LIBRARYexcelfilesbook.csv')
bdf=bdf.loc[bdf['title']==book_name]
if bdf.empty:
print('No book found in the library')
return
m_name=input('Enter member name :')
mdf=pd.raed_csv('C:LIBRARYexcelfilesmember.csv')
mdf=mdf.loc[mdf['m_name']==m_name]
if mdf.empty:
print('No such member found')
return
dateofissue=int(input('Enter date of issue :'))
noofbookissued=int(input('Enter number of book issued :'))
bdf=pd.read_csv('C:LIBRARYexcelfilesissuebooks.csv')
n=bdf['book_name'].count()
bdf.at[n]=['book_name,m_name',date.today(),noofbookissued,'']
bdf.to_csv('C:LIBRARYexcelfilesissuebooks.csv',index=False)
print('Books issued successfully')
print(bdf)
def returnBook():
m_name=input('Enter member name :')
book_name=input('Enter book name :')
idf=pd.read_csv('C:LIBRARYexcelfilesissuebooks.csv')
idf=idf.loc[idf['book_name']==book_name]
if idf.empty:
print('The book is not issued in the records')
else:
idf=idf.loc[idf['m_name']==m_name]
if idf.empty:
print('the book is not issued to the member')
else:
print('Book can be retured')
ans=input('are you sure you want to return the book?')
if ans.lower()=='yes':
idf=pd.read_csv('CLIBRARYexelfilesissuebooks.csv')
idf=idf.drop(idf[idf['book_name']==book_name].index)
idf.to_csv('CLIBRARYexcelfilesissuebooks.csv',index=False)
print('Book Returned')
else:
print('Return operation cancelled')
def showissuedBooks():
idf=pd.read_csv('C:LIBRARYexcelfilesissuebooks.csv')
print(idf)
def deleteissuedBooks():
book_name=input('enter a book name :')
bdf=pd.read_csv('C:LIBRARYexcelfilesissuebooks.csv')
bdf=bdf.drop(bdf[bdf['book_name']==book_name].index)
bdf.to_csv('C:LIBRARYexcelfilesissuebooks.csv',index=False)
print('Delated issued book successfully')
print(bdf)
def showCharts():
print('Press 1- Book and its cost')
print('Press 2- Number of books isssued by members')
ch=int(input('Enter your choice:'))
if ch==1:
df=pd.read_csv('C:LIBRARYexcelfilesbook.csv')
df=df[['title','cost']]
df.plot('title','cost','kind='bar')
plt.xlabel('---title--- ')
plt.ylabel('---cost---')
plt.show()
if ch==2:
df=pd.read_csv('C:LIBRARYexcelfilesissuebooks.csv')
df=df[['noofbooksissued','m_name']]
df.plot(kind='bar',color='red')
plt.show()
def login():
uname=input('Enter username :')
pwd=input('Enter password :')
df=pd.read_csv('C:LIBRARYexcelfilesusers.csv')
df=df.loc[df['username']==uname]
if df.empty:
print('Invalid username')
return False
else:
df=df.loc[df['password']==pwd]
if df.empty:
print('Invalid password')
return False
else:
print(':Username and password matched:')
return True
def showMenu():
print('Press 1-Add a new book')
print('Press 2-Search for a book')
print('Press 3-Delete a book')
print('Press 4-Show all books')
print('Press 5-Add a new member')
print('Press 6-Search for a member')
print('Press 7-Delete a book')
print('Press 8-Show all members')
print('Press 9-Isuue a book')
print('Press 10-Return a book')
print('Press 11-Show all isuued book')
print('Press 12-Delete an issued book')
print('Press 13-To view charts')
print('Press 14-To exit')
choice=int(input('Enter your choice: '))
return choice
if login():
while True:
ch=showMenu()
if ch==1:
addNewBook()
elif ch==2:
serchBook()
elif ch==3:
deleteBook()
elif ch==4:
showBooks()
elif ch==5:
addNewMember()
elif ch==6:
searchMember()
elif ch==7:
deleteMember()
elif ch==8:
showMembers()
elif ch==9:
issueBooks()
elif ch==10:
returnBook()
elif ch==11:
showissuedBooks()
elif ch==12:
deleteissuedBooks()
elif ch==13:
showCharts()
elif ch==14:
break
else:
print('Invalid Option')
 Outputs:
:To start the program press F5 key:
:To add new book details in the csv file:
:To search a book in the csv:
:To delete a book from csv:
:To add a new member:
:To search for a member in csv:
:To view graph chart:
SQL PROGRAM
Topic – Hotel Management
Table Name:
Desc Table:
Table:

More Related Content

What's hot

Computer science Project for class 11th and 12th(library management system)
Computer science Project for class 11th and 12th(library management system)Computer science Project for class 11th and 12th(library management system)
Computer science Project for class 11th and 12th(library management system)lokesh meena
 
How to use Map() Filter() and Reduce() functions in Python | Edureka
How to use Map() Filter() and Reduce() functions in Python | EdurekaHow to use Map() Filter() and Reduce() functions in Python | Edureka
How to use Map() Filter() and Reduce() functions in Python | EdurekaEdureka!
 
Computer science project work
Computer science project workComputer science project work
Computer science project workrahulchamp2345
 
Isc computer project final upload last
Isc computer project final upload lastIsc computer project final upload last
Isc computer project final upload lastArunav Ray
 
CBSE Class 12 Computer practical Python Programs and MYSQL
CBSE Class 12 Computer practical Python Programs and MYSQL CBSE Class 12 Computer practical Python Programs and MYSQL
CBSE Class 12 Computer practical Python Programs and MYSQL Rishabh-Rawat
 
COMPUTER SCIENCE INVESTIGATORY PROJECT 2017-18
COMPUTER SCIENCE INVESTIGATORY PROJECT 2017-18COMPUTER SCIENCE INVESTIGATORY PROJECT 2017-18
COMPUTER SCIENCE INVESTIGATORY PROJECT 2017-18HIMANSHU .
 
ZIO: Powerful and Principled Functional Programming in Scala
ZIO: Powerful and Principled Functional Programming in ScalaZIO: Powerful and Principled Functional Programming in Scala
ZIO: Powerful and Principled Functional Programming in ScalaWiem Zine Elabidine
 
COMPUTER SCIENCE CLASS 12 PRACTICAL FILE
COMPUTER SCIENCE CLASS 12 PRACTICAL FILECOMPUTER SCIENCE CLASS 12 PRACTICAL FILE
COMPUTER SCIENCE CLASS 12 PRACTICAL FILEAnushka Rai
 
Computer project final for class 12 Students
Computer project final for class 12 StudentsComputer project final for class 12 Students
Computer project final for class 12 StudentsShahban Ali
 
Computer Science Investigatory Project Class 12
Computer Science Investigatory Project Class 12Computer Science Investigatory Project Class 12
Computer Science Investigatory Project Class 12Self-employed
 
IP Project for Class 12th CBSE
IP Project for Class 12th CBSEIP Project for Class 12th CBSE
IP Project for Class 12th CBSESylvester Correya
 
Enterprise Tic-Tac-Toe
Enterprise Tic-Tac-ToeEnterprise Tic-Tac-Toe
Enterprise Tic-Tac-ToeScott Wlaschin
 
Student DATABASE MANAGeMEnT SysTEm
Student DATABASE MANAGeMEnT SysTEmStudent DATABASE MANAGeMEnT SysTEm
Student DATABASE MANAGeMEnT SysTEmhome
 
Computer science class 12 project on Super Market Billing
Computer science class 12 project on Super Market BillingComputer science class 12 project on Super Market Billing
Computer science class 12 project on Super Market BillingHarsh Kumar
 
JavaScript - Chapter 4 - Types and Statements
 JavaScript - Chapter 4 - Types and Statements JavaScript - Chapter 4 - Types and Statements
JavaScript - Chapter 4 - Types and StatementsWebStackAcademy
 

What's hot (20)

Computer science Project for class 11th and 12th(library management system)
Computer science Project for class 11th and 12th(library management system)Computer science Project for class 11th and 12th(library management system)
Computer science Project for class 11th and 12th(library management system)
 
How to use Map() Filter() and Reduce() functions in Python | Edureka
How to use Map() Filter() and Reduce() functions in Python | EdurekaHow to use Map() Filter() and Reduce() functions in Python | Edureka
How to use Map() Filter() and Reduce() functions in Python | Edureka
 
Computer science project work
Computer science project workComputer science project work
Computer science project work
 
Isc computer project final upload last
Isc computer project final upload lastIsc computer project final upload last
Isc computer project final upload last
 
CBSE Class 12 Computer practical Python Programs and MYSQL
CBSE Class 12 Computer practical Python Programs and MYSQL CBSE Class 12 Computer practical Python Programs and MYSQL
CBSE Class 12 Computer practical Python Programs and MYSQL
 
Computer Investgatort Project (HOTEL MANAGEMENT SYSTEM)
Computer Investgatort Project (HOTEL MANAGEMENT SYSTEM)Computer Investgatort Project (HOTEL MANAGEMENT SYSTEM)
Computer Investgatort Project (HOTEL MANAGEMENT SYSTEM)
 
COMPUTER SCIENCE INVESTIGATORY PROJECT 2017-18
COMPUTER SCIENCE INVESTIGATORY PROJECT 2017-18COMPUTER SCIENCE INVESTIGATORY PROJECT 2017-18
COMPUTER SCIENCE INVESTIGATORY PROJECT 2017-18
 
ZIO: Powerful and Principled Functional Programming in Scala
ZIO: Powerful and Principled Functional Programming in ScalaZIO: Powerful and Principled Functional Programming in Scala
ZIO: Powerful and Principled Functional Programming in Scala
 
COMPUTER SCIENCE CLASS 12 PRACTICAL FILE
COMPUTER SCIENCE CLASS 12 PRACTICAL FILECOMPUTER SCIENCE CLASS 12 PRACTICAL FILE
COMPUTER SCIENCE CLASS 12 PRACTICAL FILE
 
Computer project final for class 12 Students
Computer project final for class 12 StudentsComputer project final for class 12 Students
Computer project final for class 12 Students
 
Computer Science Investigatory Project Class 12
Computer Science Investigatory Project Class 12Computer Science Investigatory Project Class 12
Computer Science Investigatory Project Class 12
 
IP Project for Class 12th CBSE
IP Project for Class 12th CBSEIP Project for Class 12th CBSE
IP Project for Class 12th CBSE
 
Enterprise Tic-Tac-Toe
Enterprise Tic-Tac-ToeEnterprise Tic-Tac-Toe
Enterprise Tic-Tac-Toe
 
Student DATABASE MANAGeMEnT SysTEm
Student DATABASE MANAGeMEnT SysTEmStudent DATABASE MANAGeMEnT SysTEm
Student DATABASE MANAGeMEnT SysTEm
 
Computer science class 12 project on Super Market Billing
Computer science class 12 project on Super Market BillingComputer science class 12 project on Super Market Billing
Computer science class 12 project on Super Market Billing
 
Chapter 02 functions -class xii
Chapter 02   functions -class xiiChapter 02   functions -class xii
Chapter 02 functions -class xii
 
Zio in real world
Zio in real worldZio in real world
Zio in real world
 
polymorphism ppt
polymorphism pptpolymorphism ppt
polymorphism ppt
 
JavaScript - Chapter 4 - Types and Statements
 JavaScript - Chapter 4 - Types and Statements JavaScript - Chapter 4 - Types and Statements
JavaScript - Chapter 4 - Types and Statements
 
Chemistry
ChemistryChemistry
Chemistry
 

Similar to computer science investigatory project .pdf

Library Management Python, MySQL
Library Management Python, MySQLLibrary Management Python, MySQL
Library Management Python, MySQLDarshit Vaghasiya
 
Don't Repeat Yourself, and Automated Code Reviews
Don't Repeat Yourself, and Automated Code ReviewsDon't Repeat Yourself, and Automated Code Reviews
Don't Repeat Yourself, and Automated Code ReviewsGramener
 
COMPUTER SCIENCE PROJECT ON HISTORICAL PLACE.pptx
COMPUTER SCIENCE PROJECT ON HISTORICAL PLACE.pptxCOMPUTER SCIENCE PROJECT ON HISTORICAL PLACE.pptx
COMPUTER SCIENCE PROJECT ON HISTORICAL PLACE.pptxmv9499596
 
ANSHUL RANA - PROGRAM FILE.pptx
ANSHUL RANA - PROGRAM FILE.pptxANSHUL RANA - PROGRAM FILE.pptx
ANSHUL RANA - PROGRAM FILE.pptxjeyel85227
 
python_lab_manual_final (1).pdf
python_lab_manual_final (1).pdfpython_lab_manual_final (1).pdf
python_lab_manual_final (1).pdfkeerthu0442
 
Intern_Report.pdf
Intern_Report.pdfIntern_Report.pdf
Intern_Report.pdftegera4050
 
Micro project project co 3i
Micro project project co 3iMicro project project co 3i
Micro project project co 3iARVIND SARDAR
 
ADBMS ASSIGNMENT
ADBMS ASSIGNMENTADBMS ASSIGNMENT
ADBMS ASSIGNMENTLori Moore
 
solution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdf
solution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdfsolution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdf
solution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdfparthp5150s
 
9608 Computer Science Cambridge International AS level Pre-Release May June p...
9608 Computer Science Cambridge International AS level Pre-Release May June p...9608 Computer Science Cambridge International AS level Pre-Release May June p...
9608 Computer Science Cambridge International AS level Pre-Release May June p...Isham Rashik
 
HELP IN JAVACreate a main method and use these input files to tes.pdf
HELP IN JAVACreate a main method and use these input files to tes.pdfHELP IN JAVACreate a main method and use these input files to tes.pdf
HELP IN JAVACreate a main method and use these input files to tes.pdffatoryoutlets
 
UNIT V PYTHON.pptx python basics ppt python
UNIT V PYTHON.pptx python basics ppt pythonUNIT V PYTHON.pptx python basics ppt python
UNIT V PYTHON.pptx python basics ppt pythonSuganthiDPSGRKCW
 
computer project by sandhya ,shital,himanshi.pptx
computer project by sandhya ,shital,himanshi.pptxcomputer project by sandhya ,shital,himanshi.pptx
computer project by sandhya ,shital,himanshi.pptxIshooYadav
 
Object Oriented Programming in Python
Object Oriented Programming in PythonObject Oriented Programming in Python
Object Oriented Programming in PythonPradeep Kumar
 
Youth Tobacco Survey Analysis
Youth Tobacco Survey AnalysisYouth Tobacco Survey Analysis
Youth Tobacco Survey AnalysisRoshik Ganesan
 

Similar to computer science investigatory project .pdf (20)

Library Management Python, MySQL
Library Management Python, MySQLLibrary Management Python, MySQL
Library Management Python, MySQL
 
Don't Repeat Yourself, and Automated Code Reviews
Don't Repeat Yourself, and Automated Code ReviewsDon't Repeat Yourself, and Automated Code Reviews
Don't Repeat Yourself, and Automated Code Reviews
 
COMPUTER SCIENCE PROJECT ON HISTORICAL PLACE.pptx
COMPUTER SCIENCE PROJECT ON HISTORICAL PLACE.pptxCOMPUTER SCIENCE PROJECT ON HISTORICAL PLACE.pptx
COMPUTER SCIENCE PROJECT ON HISTORICAL PLACE.pptx
 
ANSHUL RANA - PROGRAM FILE.pptx
ANSHUL RANA - PROGRAM FILE.pptxANSHUL RANA - PROGRAM FILE.pptx
ANSHUL RANA - PROGRAM FILE.pptx
 
python_lab_manual_final (1).pdf
python_lab_manual_final (1).pdfpython_lab_manual_final (1).pdf
python_lab_manual_final (1).pdf
 
ELAVARASAN.pdf
ELAVARASAN.pdfELAVARASAN.pdf
ELAVARASAN.pdf
 
Python dictionaries
Python dictionariesPython dictionaries
Python dictionaries
 
Project3
Project3Project3
Project3
 
Intern_Report.pdf
Intern_Report.pdfIntern_Report.pdf
Intern_Report.pdf
 
Micro project project co 3i
Micro project project co 3iMicro project project co 3i
Micro project project co 3i
 
C- Programming Assignment 3
C- Programming Assignment 3C- Programming Assignment 3
C- Programming Assignment 3
 
ADBMS ASSIGNMENT
ADBMS ASSIGNMENTADBMS ASSIGNMENT
ADBMS ASSIGNMENT
 
solution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdf
solution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdfsolution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdf
solution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdf
 
9608 Computer Science Cambridge International AS level Pre-Release May June p...
9608 Computer Science Cambridge International AS level Pre-Release May June p...9608 Computer Science Cambridge International AS level Pre-Release May June p...
9608 Computer Science Cambridge International AS level Pre-Release May June p...
 
HELP IN JAVACreate a main method and use these input files to tes.pdf
HELP IN JAVACreate a main method and use these input files to tes.pdfHELP IN JAVACreate a main method and use these input files to tes.pdf
HELP IN JAVACreate a main method and use these input files to tes.pdf
 
yash shakya.pptx
yash shakya.pptxyash shakya.pptx
yash shakya.pptx
 
UNIT V PYTHON.pptx python basics ppt python
UNIT V PYTHON.pptx python basics ppt pythonUNIT V PYTHON.pptx python basics ppt python
UNIT V PYTHON.pptx python basics ppt python
 
computer project by sandhya ,shital,himanshi.pptx
computer project by sandhya ,shital,himanshi.pptxcomputer project by sandhya ,shital,himanshi.pptx
computer project by sandhya ,shital,himanshi.pptx
 
Object Oriented Programming in Python
Object Oriented Programming in PythonObject Oriented Programming in Python
Object Oriented Programming in Python
 
Youth Tobacco Survey Analysis
Youth Tobacco Survey AnalysisYouth Tobacco Survey Analysis
Youth Tobacco Survey Analysis
 

Recently uploaded

Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 

Recently uploaded (20)

9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 

computer science investigatory project .pdf

  • 2. KENDRIYA VIDHYALAYA JANAKPURI ACADEMIC YEAR :- 2022-2023 STUDENT DETAIL ROLL NO. :- 26633855 NAME :- ARYAN NAGLOT CLASS :- XII-B SUBJECT AND CODE :- COMPUTER SCIENCE
  • 3. CERTIFICATE NAME :- ARYAN NAGLOT CLASS :- XII-B ROLL NO. :- 26633855 This is certified to be he Bonafede work of the student in the Kendriya Vidyalaya Janakpuri during the academic year 2022-2023. ___________________________ SUBJECT TEACHER SIGNATURE _____________________ EXAMINER’S SIGNATURE ____________________ PRINCIPAL SIGNATURE
  • 4. ACKNOWLEDGEMENT I would like to thank my informatics practices teacher, Sonia Sharma mam, whose valuable guidance has been the ones that have helped me patch this project. Her suggestions and instructions have served as the major contributions towards the completion of the project. Then I would like to thank my parents and friends who have helped me with their valuable suggestions and guidance that has been helpful in various phase of the completion of this project. ~ ARYAN NAGLOT
  • 5. QUESTION BASED PROGRAMS 1. WAP to show functionality of a basic calculator using functions. def calculator(n1,n2,oper): if oper=='+': return n1+n2 elif oper=='-': return n1-n2 elif oper=='*': return n1*n2 elif oper=='/': return n1/n2 elif oper=='//': return n1//n2 elif oper=='%': return n1%n2 else: print('invalid operator..') return 0 num1=float(input('enter first number:')) num2=float(input('enter second number:')) op=input('input operator among +,-,*,/,//,%:') print(calculator(num1,num2,op)) **************************************************************************************************** 2. Write a function in python which accept a number from user to return True, if the number is a prime number else return False. Use this function to print all prime numbers from 1 to 100. def checkPrime(n): for i in range (2, n): if n%i==0: return False else: return True l=[] for i in range(1,101): ans=checkPrime(i) if ans==True: l.append(i) print('Prime numbers between 1 to 100=',l) **************************************************************************************************** 3. Write a function in python which accept a list of marks of students and return the minimum mark, maximum mark and the average marks. Use the same function to test. def checkList(l): return min(l),max(l),(sum(l)/len(l)) marks=eval(input('enter the marks of students:')) minList,maxList,avgList=checkList(marks) print('MAXIMUM MARKS:',maxList)
  • 6. print('MINIMUM MARKS:',minList) print('AVERAGE MARKS:',avgList) **************************************************************************************************** 4. WAP to read a text file “myfile.txt” line by line and display each word separated by a #. f=open(r'C:UsersComp_Lab_IIDesktopmyfile.txt') def show(): try: while True: data=f.readline() data=data.split() for i in data: print(i,'#',end='') except: f.close() show() **************************************************************************************************** 5. WAP to read a text file “myfile.txt” and display the number of vowels/ consonants/ uppercase/ lowercase characters in the file. def show(): f=open(r'C:UsersComp_Lab_IIDesktopmyfile.txt') data=f.read() vowal=0 cons=0 uper=0 low=0 vowalList=['A','E','I','O','U','a','e','i','o','u'] for i in data: if i.isalpha()==True: if i in vowalList: vowal+=1 else: cons+=1 if i.isupper(): uper+=1 else: low+=1 print('number of vowels:',vowal) print('number of consonants:',cons) print('number of Capital letters:',uper) print('number of small letters:',low) show() **************************************************************************************************** 6. Remove all the lines that contain the character `a' in a file and write it to another file. def copyData(): f=open(r'C:UsersComp_Lab_IIDesktopmyfile.txt') f2=open(r'C:UsersComp_Lab_IIDesktopmyfile2.txt','w+') data=f.readlines()
  • 7. for line in data: if 'A' not in line: if 'a' not in line: f2.write(line) f2.flush() f2.seek(0) data2=f2.read() print(data2) f.close() f2.close() copyData() OR def copyData(): f=open(r'C:UsersComp_Lab_IIDesktopmyfile.txt') f2=open(r'C:UsersComp_Lab_IIDesktopmyfile3.txt','w+') data=f.readlines() for line in data: if 'A' not in line and 'a' not in line: f2.write(line) f2.flush() f2.seek(0) data2=f2.read() print(data2) f.close() f2.close() copyData() **************************************************************************************************** 7. Write a program to create a text file and print the lines starting with ‘T’ or ‘P’. (Both uppercase and lowercase). def printData(): f=open(r'C:UsersComp_Lab_IIDesktopmyfile.txt') data=f.readlines() for line in data: L1=['t','T','P','p'] if line[0] in L1: print(line) f.close() printData() **************************************************************************************************** 8. Read a text file to print the frequency of the word ‘He’ and ‘She’ found in the file. def readHeShe(): file=open(r'C:UsersComp_Lab_IIDesktopmyfile.txt') data=file.read() cntHe=0 cntShe=0 data=data.split()
  • 8. for i in data: i=i.lower() if i=='he': cntHe+=1 elif i=='she': cntShe+=1 else: continue print('Frequency of "He" in file=',cntHe) print('Frequency of "She" in file=',cntShe) readHeShe() **************************************************************************************************** 9. Create a binary file with name and roll number. Search for a given roll number and display the name, if not found display appropriate message. import pickle file=open(r'D:myBinaryFile.bin','ab+') def inputData(): ans='y' while ans=='y': data=eval(input('enter the name and roll number of student:')) pickle.dump(data,file) file.flush() ans=input('want to enter more data? Press Y or N') ans=ans.lower() def searchData(): file.seek(0) try: found=False rno=int(input('enter the roll number to search:')) while True: data=pickle.load(file) if data['roll number']==rno: found=True nm=data['name'] print('ROLL NUMBER=',rno,' AND NAME=',data['name']) except: if found==True: print('data found..') else: print('data not found..') file.close() inputData() searchData() **************************************************************************************************** 10. Create a binary file with roll number, name and marks. Input a roll number and update the marks. import pickle file=open(r'D:myBinaryFile2.bin','wb+') def inputData():
  • 9. ans='y' while ans=='y': data=eval(input('enter the name, roll number and marks of student:')) pickle.dump(data,file) file.flush() ans=input('want to enter more data? Press Y or N') ans=ans.lower() def updateMarks(): file.seek(0) try: rno=int(input('enter the roll number to search:')) newMarks=int(input('enter new marks')) while True: pos=file.tell() data=pickle.load(file) if data['roll number']==rno: data['marks']=newMarks file.seek(pos) pickle.dump(data,file) file.flush() print('ROLL NUMBER=',data['roll number'],' AND NEW MARKS=',data['marks']) except: file.close() def show(): file=open(r'D:myBinaryFile2.bin','rb+') try: while True: data=pickle.load(file) print(data) except: file.close() inputData() updateMarks() show() **************************************************************************************************** 11. Read a CSV file from hard disc and print all the details on the screen. def readCSV(): file=open(r'D:saurav.csv',newline='n') readerObj=csv.reader(file) for i in readerObj: print(i) file.close() readCSV() **************************************************************************************************** 12. Read a CSV file (containing item no, name, rate, QOH) from hard disc and print all the items whose rate is between Rs 500 and Rs 1000. def readCSV(): file=open(r'D:saurav2.csv',newline='n')
  • 10. readerObj=csv.reader(file) for i in readerObj: if i[2].isalpha()==True: continue else: if float(i[2])>=500 and float(i[2])<=1000: print(i[1]) file.close() readCSV() **************************************************************************************************** 13. Create a CSV file by entering user-id and password, read and search the password for given userid. file=open(r'D:saurav3.csv','a+',newline='n') def writeCSV(): writerObj=csv.writer(file) writerObj.writerow(['user-id','password']) ans='y' while ans=='y': uid=input('enter user id:') pwd=input('enter password:') writerObj.writerow([uid,pwd]) file.flush() ans=input('want to add more info? y or n..') ans=ans.lower() print('data saved successfully..') def search(): file.seek(0) uid=input('enter the id to search:') readerObj=csv.reader(file) for i in readerObj: if i[0]==uid: print('password=',i[1]) writeCSV() search() file.close() **************************************************************************************************** 14. Write a random number generator that generates random numbers between 1 and 6 (simulates a dice). Throw the two dices for 10 times and print their total. def rolladice(): counter = 1 myList = [] while counter <= 10: randomNumber = random.randint(1,6) #print('value of 1 dice ',counter,' time=',randomNumber) randomNumber2=random.randint(1,6) #print('value of 2 dice ',counter,' time=',randomNumber2) myList.append(randomNumber+randomNumber2) counter = counter + 1
  • 11. return myList # Take user input here print(rolladice()) **************************************************************************************************** 15. WAP in Python to demonstrate linear search. def LinearSearch(): list1=eval(input('enter the list of elements:')) element=eval(input('enter the element to search:')) found=0 for i in list1: if i==element: found=1 position=list1.index(i)+1 else: continue if found==1: print('element found in ',position,' position') else: print('element not found..') LinearSearch() **************************************************************************************************** 16. Write a Python program to implement a stack using a list data-structure. status=[] def Push_element(list1): status.append(list1) def Pop_element(): while len(status)>0: print(status.pop()) else: print('Stack Empty..') for i in range(5): list1=eval(input('enter the list:')) Push_element(list1) Pop_element() **************************************************************************************************** 17. WAP to pass an integer list as stack to a function and push only those elements in the stack which are divisible by 7. status=[] def Push_element(list1): for i in list1: if i% 7==0: status.append(i) print(status) list1=eval(input('enter the integer list:')) Push_element(list1) ****************************************************************************************************
  • 12.
  • 13. CSV TABLE PROGRAM # CSV TABLES: import pandas as pd import matplotlib as pyplot from datetime import date print("Welcome to ABC Library") def addNewMember(): mid=int(input('Enter member id :')) m_name=input('Enter member name :') phoneno=int(input('Enter phone number :')) noofbooksissued=0 mdf=pd.read_csv('CLIBRARYexcelfilesmember.csv') n=mdf['mid'].count() mdf.at[n]=[mid,m_name,phoneno,noofbooksissued] mdf.to_csv('CLIBRARYexcel filesmember.csv,'index=False) print('New member added') print(mdf) def searchMember(): m_name=input('Enter member name:') bdf=pd.read_csv('C:LIBRARYexcelfilesmember.csv') df=bdf.loc[bdf['mname']--m_name] if df.empty: print('No member found with this name') else: print('Members details:') print(df) def deleteMember(): mid = float(input('Enter member id :')) bdf=pd.read_csv('CLIBRARYexcelfilesmembers.csv') bdf=bdf.drop(bdf[bdf['mid']==mid].index) bdf.to_csv('C:LIBRARYexcel filesmember.csv',index=False) print('Member deleted') print(bdf) def showMembers(): bdf=pd.read_csv('C:LIBRARYexcelfilesmember.csv') print(bdf) def addNewBook(): bookid=int(input('Enter a bok id:')) title=input('Enter book title:') author=input('Enter author of the book:') publisher=input('Enter book publisher:')
  • 14. edition=input('Enter edition of the book:') cost=input('Enter cost of the book:') category=input('Enter category of the book:') bdf=pd.read_csv("C:LIBRARYexcelfilesbook.csv") n=bdf['bookid'].count() bdf.at[n]=[bookid,title,author,publisher,edition,cost,category] bdf.to_csv(r"C:LIBRARYexcelfilesbook.csv",index=False) print('Book added successfully') print(bdf) def searchBook(): title=input('Enter a book name : ') bdf=pd.read_csv('C:LIBRARYexcelfilesbook.csv') df=bdf.loc[bdf['title']==title] if df.empty: print('no book found with this code') else: print('Book details:') print(df) def deleteBook(): bookid=float(input('Enter book id :')) bdf=pd.read_csv(r'C:LIBRARYexcel filesbook.csv') bdf=bdf.drop(bdf[bdf['bookid']--bookid].index) bdf.to_csv('C:LIBRARYexcelfilesbook.csv',index=False) print("Book deleted") print(bdf) def showBooks(): bdf=pd.read_csv('C:LIBRARYexcelfilesbook.csv') print(bdf) def issueBooks(): book_name=input('Enter book name:') bdf=pd.read_csv('C:LIBRARYexcelfilesbook.csv') bdf=bdf.loc[bdf['title']==book_name] if bdf.empty: print('No book found in the library') return m_name=input('Enter member name :') mdf=pd.raed_csv('C:LIBRARYexcelfilesmember.csv') mdf=mdf.loc[mdf['m_name']==m_name] if mdf.empty: print('No such member found') return dateofissue=int(input('Enter date of issue :')) noofbookissued=int(input('Enter number of book issued :')) bdf=pd.read_csv('C:LIBRARYexcelfilesissuebooks.csv') n=bdf['book_name'].count() bdf.at[n]=['book_name,m_name',date.today(),noofbookissued,''] bdf.to_csv('C:LIBRARYexcelfilesissuebooks.csv',index=False)
  • 15. print('Books issued successfully') print(bdf) def returnBook(): m_name=input('Enter member name :') book_name=input('Enter book name :') idf=pd.read_csv('C:LIBRARYexcelfilesissuebooks.csv') idf=idf.loc[idf['book_name']==book_name] if idf.empty: print('The book is not issued in the records') else: idf=idf.loc[idf['m_name']==m_name] if idf.empty: print('the book is not issued to the member') else: print('Book can be retured') ans=input('are you sure you want to return the book?') if ans.lower()=='yes': idf=pd.read_csv('CLIBRARYexelfilesissuebooks.csv') idf=idf.drop(idf[idf['book_name']==book_name].index) idf.to_csv('CLIBRARYexcelfilesissuebooks.csv',index=False) print('Book Returned') else: print('Return operation cancelled') def showissuedBooks(): idf=pd.read_csv('C:LIBRARYexcelfilesissuebooks.csv') print(idf) def deleteissuedBooks(): book_name=input('enter a book name :') bdf=pd.read_csv('C:LIBRARYexcelfilesissuebooks.csv') bdf=bdf.drop(bdf[bdf['book_name']==book_name].index) bdf.to_csv('C:LIBRARYexcelfilesissuebooks.csv',index=False) print('Delated issued book successfully') print(bdf) def showCharts(): print('Press 1- Book and its cost') print('Press 2- Number of books isssued by members') ch=int(input('Enter your choice:')) if ch==1: df=pd.read_csv('C:LIBRARYexcelfilesbook.csv') df=df[['title','cost']] df.plot('title','cost','kind='bar') plt.xlabel('---title--- ') plt.ylabel('---cost---') plt.show() if ch==2: df=pd.read_csv('C:LIBRARYexcelfilesissuebooks.csv') df=df[['noofbooksissued','m_name']] df.plot(kind='bar',color='red') plt.show()
  • 16. def login(): uname=input('Enter username :') pwd=input('Enter password :') df=pd.read_csv('C:LIBRARYexcelfilesusers.csv') df=df.loc[df['username']==uname] if df.empty: print('Invalid username') return False else: df=df.loc[df['password']==pwd] if df.empty: print('Invalid password') return False else: print(':Username and password matched:') return True def showMenu(): print('Press 1-Add a new book') print('Press 2-Search for a book') print('Press 3-Delete a book') print('Press 4-Show all books') print('Press 5-Add a new member') print('Press 6-Search for a member') print('Press 7-Delete a book') print('Press 8-Show all members') print('Press 9-Isuue a book') print('Press 10-Return a book') print('Press 11-Show all isuued book') print('Press 12-Delete an issued book') print('Press 13-To view charts') print('Press 14-To exit') choice=int(input('Enter your choice: ')) return choice if login(): while True: ch=showMenu() if ch==1: addNewBook() elif ch==2: serchBook() elif ch==3: deleteBook() elif ch==4: showBooks() elif ch==5: addNewMember() elif ch==6: searchMember() elif ch==7: deleteMember()
  • 17. elif ch==8: showMembers() elif ch==9: issueBooks() elif ch==10: returnBook() elif ch==11: showissuedBooks() elif ch==12: deleteissuedBooks() elif ch==13: showCharts() elif ch==14: break else: print('Invalid Option')
  • 18.  Outputs: :To start the program press F5 key: :To add new book details in the csv file:
  • 19. :To search a book in the csv: :To delete a book from csv:
  • 20. :To add a new member: :To search for a member in csv:
  • 21. :To view graph chart:
  • 22. SQL PROGRAM Topic – Hotel Management Table Name: Desc Table: