SlideShare a Scribd company logo
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

Chapter 02 functions -class xii
Chapter 02   functions -class xiiChapter 02   functions -class xii
Chapter 02 functions -class xii
Praveen M Jigajinni
 
Python Flavors
Python FlavorsPython Flavors
Python Flavors
Geison Goes
 
Programming in C Lab
Programming in C LabProgramming in C Lab
Programming in C Lab
Neil Mathew
 
Java Foundations: Basic Syntax, Conditions, Loops
Java Foundations: Basic Syntax, Conditions, LoopsJava Foundations: Basic Syntax, Conditions, Loops
Java Foundations: Basic Syntax, Conditions, Loops
Svetlin Nakov
 
Python : Regular expressions
Python : Regular expressionsPython : Regular expressions
Python : Regular expressions
Emertxe Information Technologies Pvt Ltd
 
Dictionnaire de mathématiques
Dictionnaire de mathématiquesDictionnaire de mathématiques
Dictionnaire de mathématiques
salah fenni
 
Python for Machine Learning
Python for Machine LearningPython for Machine Learning
Python for Machine Learning
Student
 
Revised Data Structure- STACK in Python XII CS.pdf
Revised Data Structure- STACK in Python XII CS.pdfRevised Data Structure- STACK in Python XII CS.pdf
Revised Data Structure- STACK in Python XII CS.pdf
MohammadImran709594
 
Strings Functions in C Programming
Strings Functions in C ProgrammingStrings Functions in C Programming
Strings Functions in C Programming
DevoAjit Gupta
 
Python Datatypes by SujithKumar
Python Datatypes by SujithKumarPython Datatypes by SujithKumar
Python Datatypes by SujithKumar
Sujith Kumar
 
Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output) Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output)
Aman Deep
 
Nesting of for loops using C++
Nesting of for loops using C++Nesting of for loops using C++
Nesting of for loops using C++
prashant_sainii
 
Chapter 08 data file handling
Chapter 08 data file handlingChapter 08 data file handling
Chapter 08 data file handling
Praveen M Jigajinni
 
List,tuple,dictionary
List,tuple,dictionaryList,tuple,dictionary
List,tuple,dictionary
nitamhaske
 
Data handling CBSE PYTHON CLASS 11
Data handling CBSE PYTHON CLASS 11Data handling CBSE PYTHON CLASS 11
Data handling CBSE PYTHON CLASS 11
chinthala Vijaya Kumar
 
Sorting & Linked Lists
Sorting & Linked ListsSorting & Linked Lists
Sorting & Linked Lists
J.T.A.JONES
 
Project of data structure
Project of data structureProject of data structure
Project of data structure
Umme habiba
 
DataFrame in Python Pandas
DataFrame in Python PandasDataFrame in Python Pandas
DataFrame in Python Pandas
Sangita Panchal
 
VTU DSA Lab Manual
VTU DSA Lab ManualVTU DSA Lab Manual
VTU DSA Lab Manual
AkhilaaReddy
 
Python strings
Python stringsPython strings
Python strings
Mohammed Sikander
 

What's hot (20)

Chapter 02 functions -class xii
Chapter 02   functions -class xiiChapter 02   functions -class xii
Chapter 02 functions -class xii
 
Python Flavors
Python FlavorsPython Flavors
Python Flavors
 
Programming in C Lab
Programming in C LabProgramming in C Lab
Programming in C Lab
 
Java Foundations: Basic Syntax, Conditions, Loops
Java Foundations: Basic Syntax, Conditions, LoopsJava Foundations: Basic Syntax, Conditions, Loops
Java Foundations: Basic Syntax, Conditions, Loops
 
Python : Regular expressions
Python : Regular expressionsPython : Regular expressions
Python : Regular expressions
 
Dictionnaire de mathématiques
Dictionnaire de mathématiquesDictionnaire de mathématiques
Dictionnaire de mathématiques
 
Python for Machine Learning
Python for Machine LearningPython for Machine Learning
Python for Machine Learning
 
Revised Data Structure- STACK in Python XII CS.pdf
Revised Data Structure- STACK in Python XII CS.pdfRevised Data Structure- STACK in Python XII CS.pdf
Revised Data Structure- STACK in Python XII CS.pdf
 
Strings Functions in C Programming
Strings Functions in C ProgrammingStrings Functions in C Programming
Strings Functions in C Programming
 
Python Datatypes by SujithKumar
Python Datatypes by SujithKumarPython Datatypes by SujithKumar
Python Datatypes by SujithKumar
 
Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output) Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output)
 
Nesting of for loops using C++
Nesting of for loops using C++Nesting of for loops using C++
Nesting of for loops using C++
 
Chapter 08 data file handling
Chapter 08 data file handlingChapter 08 data file handling
Chapter 08 data file handling
 
List,tuple,dictionary
List,tuple,dictionaryList,tuple,dictionary
List,tuple,dictionary
 
Data handling CBSE PYTHON CLASS 11
Data handling CBSE PYTHON CLASS 11Data handling CBSE PYTHON CLASS 11
Data handling CBSE PYTHON CLASS 11
 
Sorting & Linked Lists
Sorting & Linked ListsSorting & Linked Lists
Sorting & Linked Lists
 
Project of data structure
Project of data structureProject of data structure
Project of data structure
 
DataFrame in Python Pandas
DataFrame in Python PandasDataFrame in Python Pandas
DataFrame in Python Pandas
 
VTU DSA Lab Manual
VTU DSA Lab ManualVTU DSA Lab Manual
VTU DSA Lab Manual
 
Python strings
Python stringsPython strings
Python strings
 

Similar to computer science investigatory project .pdf

Library Management Python, MySQL
Library Management Python, MySQLLibrary Management Python, MySQL
Library Management Python, MySQL
Darshit 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 Reviews
Gramener
 
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
mv9499596
 
ANSHUL RANA - PROGRAM FILE.pptx
ANSHUL RANA - PROGRAM FILE.pptxANSHUL RANA - PROGRAM FILE.pptx
ANSHUL RANA - PROGRAM FILE.pptx
jeyel85227
 
python_lab_manual_final (1).pdf
python_lab_manual_final (1).pdfpython_lab_manual_final (1).pdf
python_lab_manual_final (1).pdf
keerthu0442
 
ELAVARASAN.pdf
ELAVARASAN.pdfELAVARASAN.pdf
ELAVARASAN.pdf
dharmendra kumar jaiswal
 
Python dictionaries
Python dictionariesPython dictionaries
Python dictionaries
Krishna Nanda
 
Student DATABASE MANAGeMEnT SysTEm
Student DATABASE MANAGeMEnT SysTEmStudent DATABASE MANAGeMEnT SysTEm
Student DATABASE MANAGeMEnT SysTEm
home
 
Project3
Project3Project3
Project3
ARVIND SARDAR
 
Intern_Report.pdf
Intern_Report.pdfIntern_Report.pdf
Intern_Report.pdf
tegera4050
 
Unit4-Basic Concepts and methods of Dictionary.pptx
Unit4-Basic Concepts and methods of Dictionary.pptxUnit4-Basic Concepts and methods of Dictionary.pptx
Unit4-Basic Concepts and methods of Dictionary.pptx
SwapnaliGawali5
 
Micro project project co 3i
Micro project project co 3iMicro project project co 3i
Micro project project co 3i
ARVIND SARDAR
 
C- Programming Assignment 3
C- Programming Assignment 3C- Programming Assignment 3
C- Programming Assignment 3
Animesh Chaturvedi
 
ADBMS ASSIGNMENT
ADBMS ASSIGNMENTADBMS ASSIGNMENT
ADBMS ASSIGNMENT
Lori 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).pdf
parthp5150s
 
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.pdf
fatoryoutlets
 
yash shakya.pptx
yash shakya.pptxyash shakya.pptx
yash shakya.pptx
yashshakya13
 
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
SuganthiDPSGRKCW
 
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
IshooYadav
 

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
 
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
 
Unit4-Basic Concepts and methods of Dictionary.pptx
Unit4-Basic Concepts and methods of Dictionary.pptxUnit4-Basic Concepts and methods of Dictionary.pptx
Unit4-Basic Concepts and methods of Dictionary.pptx
 
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
 

Recently uploaded

Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
ImMuslim
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
siemaillard
 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
imrankhan141184
 
How Barcodes Can Be Leveraged Within Odoo 17
How Barcodes Can Be Leveraged Within Odoo 17How Barcodes Can Be Leveraged Within Odoo 17
How Barcodes Can Be Leveraged Within Odoo 17
Celine George
 
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
EduSkills OECD
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
iammrhaywood
 
skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)
Mohammad Al-Dhahabi
 
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
indexPub
 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Henry Hollis
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
Krassimira Luka
 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
deepaannamalai16
 
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptxBIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
RidwanHassanYusuf
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
EduSkills OECD
 
Educational Technology in the Health Sciences
Educational Technology in the Health SciencesEducational Technology in the Health Sciences
Educational Technology in the Health Sciences
Iris Thiele Isip-Tan
 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
PsychoTech Services
 
CIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdfCIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdf
blueshagoo1
 
Bossa N’ Roll Records by Ismael Vazquez.
Bossa N’ Roll Records by Ismael Vazquez.Bossa N’ Roll Records by Ismael Vazquez.
Bossa N’ Roll Records by Ismael Vazquez.
IsmaelVazquez38
 
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdfمصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
سمير بسيوني
 
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
TechSoup
 

Recently uploaded (20)

Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
 
How Barcodes Can Be Leveraged Within Odoo 17
How Barcodes Can Be Leveraged Within Odoo 17How Barcodes Can Be Leveraged Within Odoo 17
How Barcodes Can Be Leveraged Within Odoo 17
 
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
 
skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)
 
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
 
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptxBIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
 
Educational Technology in the Health Sciences
Educational Technology in the Health SciencesEducational Technology in the Health Sciences
Educational Technology in the Health Sciences
 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
 
CIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdfCIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdf
 
Bossa N’ Roll Records by Ismael Vazquez.
Bossa N’ Roll Records by Ismael Vazquez.Bossa N’ Roll Records by Ismael Vazquez.
Bossa N’ Roll Records by Ismael Vazquez.
 
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdfمصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
 
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
 

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: