SlideShare une entreprise Scribd logo
1  sur  23
Télécharger pour lire hors ligne
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:

Contenu connexe

Tendances

What is Tuple in python? | Python Tuple Tutorial | Edureka
What is Tuple in python? | Python Tuple Tutorial | EdurekaWhat is Tuple in python? | Python Tuple Tutorial | Edureka
What is Tuple in python? | Python Tuple Tutorial | EdurekaEdureka!
 
Corps and division in pakistan army
Corps and division in pakistan armyCorps and division in pakistan army
Corps and division in pakistan armyKhesrau Hayat
 
review of "In the Line of Fire" by Gen(R) Musharaf
review of "In the Line of Fire" by Gen(R) Musharafreview of "In the Line of Fire" by Gen(R) Musharaf
review of "In the Line of Fire" by Gen(R) Musharafganzaslar
 
Pak US relations Report
Pak US relations ReportPak US relations Report
Pak US relations ReportAreej Fatima
 
Politics of Pakistan 2008 to 2014
Politics of Pakistan 2008 to 2014Politics of Pakistan 2008 to 2014
Politics of Pakistan 2008 to 2014Ahmad Ali
 
PROBLEMS OF PAKISTAN AND THEIR SOLUTION
PROBLEMS OF PAKISTAN AND THEIR SOLUTIONPROBLEMS OF PAKISTAN AND THEIR SOLUTION
PROBLEMS OF PAKISTAN AND THEIR SOLUTIONAhsan Sulehria
 
Computer Science Practical File class XII
Computer Science Practical File class XIIComputer Science Practical File class XII
Computer Science Practical File class XIIYugenJarwal
 
Salient features of pakistan economy
Salient features of pakistan economySalient features of pakistan economy
Salient features of pakistan economywaqasawan007
 
Furturistic outlook of pakistan
Furturistic outlook of pakistanFurturistic outlook of pakistan
Furturistic outlook of pakistanAli Raza
 
Transportation and communication of pakistan
Transportation and communication of pakistanTransportation and communication of pakistan
Transportation and communication of pakistanAwais Munir
 
Problems of pakistan and their solutions
Problems of pakistan and their solutionsProblems of pakistan and their solutions
Problems of pakistan and their solutionsHassaan Bin Jalil
 
Lists in Python
Lists in PythonLists in Python
Lists in PythonPooja B S
 
Resources of Pakistan
Resources of Pakistan Resources of Pakistan
Resources of Pakistan Ayesha Shoukat
 
Benazir bhutto By Dr. Zafar Iqbal
Benazir bhutto By Dr. Zafar IqbalBenazir bhutto By Dr. Zafar Iqbal
Benazir bhutto By Dr. Zafar IqbalFreelanced
 

Tendances (20)

What is Tuple in python? | Python Tuple Tutorial | Edureka
What is Tuple in python? | Python Tuple Tutorial | EdurekaWhat is Tuple in python? | Python Tuple Tutorial | Edureka
What is Tuple in python? | Python Tuple Tutorial | Edureka
 
Corps and division in pakistan army
Corps and division in pakistan armyCorps and division in pakistan army
Corps and division in pakistan army
 
review of "In the Line of Fire" by Gen(R) Musharaf
review of "In the Line of Fire" by Gen(R) Musharafreview of "In the Line of Fire" by Gen(R) Musharaf
review of "In the Line of Fire" by Gen(R) Musharaf
 
Pak US relations Report
Pak US relations ReportPak US relations Report
Pak US relations Report
 
Politics of Pakistan 2008 to 2014
Politics of Pakistan 2008 to 2014Politics of Pakistan 2008 to 2014
Politics of Pakistan 2008 to 2014
 
PROBLEMS OF PAKISTAN AND THEIR SOLUTION
PROBLEMS OF PAKISTAN AND THEIR SOLUTIONPROBLEMS OF PAKISTAN AND THEIR SOLUTION
PROBLEMS OF PAKISTAN AND THEIR SOLUTION
 
Computer Science Practical File class XII
Computer Science Practical File class XIIComputer Science Practical File class XII
Computer Science Practical File class XII
 
External challenges to pakistan
External challenges to pakistanExternal challenges to pakistan
External challenges to pakistan
 
Legal framework order 1970
Legal framework order 1970Legal framework order 1970
Legal framework order 1970
 
Salient features of pakistan economy
Salient features of pakistan economySalient features of pakistan economy
Salient features of pakistan economy
 
Python Regular Expressions
Python Regular ExpressionsPython Regular Expressions
Python Regular Expressions
 
Furturistic outlook of pakistan
Furturistic outlook of pakistanFurturistic outlook of pakistan
Furturistic outlook of pakistan
 
Chapter 02 functions -class xii
Chapter 02   functions -class xiiChapter 02   functions -class xii
Chapter 02 functions -class xii
 
Transportation and communication of pakistan
Transportation and communication of pakistanTransportation and communication of pakistan
Transportation and communication of pakistan
 
Problems of pakistan and their solutions
Problems of pakistan and their solutionsProblems of pakistan and their solutions
Problems of pakistan and their solutions
 
Economy of pakistan
Economy of pakistanEconomy of pakistan
Economy of pakistan
 
Lists in Python
Lists in PythonLists in Python
Lists in Python
 
Economy of Pakistan & its Issues
Economy of Pakistan & its IssuesEconomy of Pakistan & its Issues
Economy of Pakistan & its Issues
 
Resources of Pakistan
Resources of Pakistan Resources of Pakistan
Resources of Pakistan
 
Benazir bhutto By Dr. Zafar Iqbal
Benazir bhutto By Dr. Zafar IqbalBenazir bhutto By Dr. Zafar Iqbal
Benazir bhutto By Dr. Zafar Iqbal
 

Similaire à 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
 
Student DATABASE MANAGeMEnT SysTEm
Student DATABASE MANAGeMEnT SysTEmStudent DATABASE MANAGeMEnT SysTEm
Student DATABASE MANAGeMEnT SysTEmhome
 
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
 

Similaire à 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
 
Student DATABASE MANAGeMEnT SysTEm
Student DATABASE MANAGeMEnT SysTEmStudent DATABASE MANAGeMEnT SysTEm
Student DATABASE MANAGeMEnT SysTEm
 
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
 

Dernier

Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 

Dernier (20)

Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 

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: