Cbse Computer Science Project
Cbse Computer Science Project
SCIENCE PROJECT
1. Introduction
3. Source Code
4. Output
5. Limitations
7. Requirements
8. Bibliography
Introduction
2. turtle
3. matplotlib
Source Code
Main code
#>>>>>Computer Science Project<<<<<
#To recognize and store voice
import speech_recognition as sr
#Tell jokes
import pyjokes
#For translation
from translate import Translator
#Declare voice
engine=pyttsx3.init()
voices = engine.getProperty('voices')
engine.setProperty('voice',voices[0].id)
def take_command():
try:
#Python listens
with sr.Microphone() as source:
print()
print("Listening...")
voice=listner.listen(source)
command=listner.recognize_google(voice)
command=command.lower()
time =
datetime.datetime.now().strftime('%I:%M %p')
if 'python' in command:
with open("python_history.txt","a") as
fp:
fp.write(d1+' : '+time+"\n")
fp.write(command+"\n")
fp.write("\n")
command=command.replace('python ','')
print(command)
except:
return None
return command
while True:
command=take_command()
if command== None:
continue
if 'play' in command:
song=command.replace('play ','')
print("The song",song,"is being played")
talk('playing'+song)
pywhatkit.playonyt(song)
translator=
Translator(from_lang=org,to_lang=conv)
translation = translator.translate(text)
print( translation)
else:
talk('sorry,can you repeat')
Butter code (Business game source keeper)
def display():
a=input("Do you want to start the game?(y/n)")
if a=='y':
x=int(input("Enter the starting money for
player 1"))
y=int(input("Enter the starting money for
player 2"))
player1=input("Enter name of player 1")
player2=input("Enter name for player 2")
l1=[]
l2=[]
mortage1=[]
mortage2=[]
while True:
print("view money, pay rent, add site, mortage
site,view sites owned,pay to bank,collect from bank,pay
player")
option=input("Choose any of the above actions")
if option=="view money":
print("money for ",player1 ,"=",x)
print("Money for ",player2 ,"=",y)
if giver==player1:
if x-amount>=0:
x=x-amount
y=y+amount
print("money remaining for
",player1,"=",x)
print("money remaining for
",player2,"=",y)
elif x-amount<0:
print("Can't make transactions ,
not enough money")
elif giver==player2:
if y-amount>=0:
y=y-amount
x=x+amount
print("money remaining for
",player1,"=",x)
print("money remaining for
",player2,"=",y)
elif y-amount<0:
print("Can't make transactions ,
not enough money")
if name1==player1:
if x-price>=0:
l1.append(site1)
x=x-price
print("sites owned
by",player1,":",l1)
print("remaining money=",x)
elif x-price<0:
print("Can't make transactions ,
not enough money")
elif name1==player2:
if y-price>=0:
l2.append(site1)
y=y-price
print("sites owned
by",player2,":",l2)
print("remaining money=",x)
elif y-price<0:
print("Can't make transactions ,
not enough money")
if name2==player1:
x=x+value
l1.remove(site2)
mortage1.append(site2)
print("sites owned by",player1,":",l1)
print("sites mortaged
by",player1,":",mortage1)
elif name2==player2:
y=y+value
l2.remove(site2)
mortage2.append(site2)
print("sites owned by",player2,":",l2)
print("sites mortaged
by",player2,":",mortage2)
if name3==player1:
if x-value2>=0:
x=x-value2
print("remaining balance:",x)
elif x-value2<0:
print("Can't make transactions ,
not enough money")
elif name3==player2:
if y-value2>=0:
y=y-value2
print("remaining balance:",y)
elif y-value2<0:
print("Can't make transactions ,
not enough money")
if name4==player1:
x=x+value3
print("remaining balance:",x)
elif name4==player2:
y=y+value3
print("remaining balance:",y)
if name5==player1:
if x-value4>=0:
x=x-value4
y=y+value4
print(player1,"current
balance=",x)
print(player2,"current
balance=",y)
elif x-value4<0:
print("Can't make transactions
, not enough money")
if name5==player2:
if y-value4>=0:
y=y-value4
x=x+value4
print(player1,"current
balance=",x)
print(player2,"current
balance=",y)
elif y-value4<0:
print("Can't make transactions
, not enough money")
if a in l:
d={}
d2={"one year":"Rs.1000/- per year",
"two year":"Rs.2000/- once in two year",
"Life time":"Rs.1500/- per year"
}
while True:
l=[]
name=input("Enter your name")
cont=input("Enter your contact number")
email=input("Enter your email address")
duration=input("Enter the duration of the
membership:")
l.append(cont)
l.append(email)
l.append(duration)
d[name]=l
#Membership card
t=turtle.Turtle()
wn = turtle.Screen()
wn.title("Membership Card")
wn.bgcolor("orange")
wn.setup(width=1300, height=500)
t.hideturtle()
t.penup()
t.goto(-400,140)
t.pendown()
t.color('black')
x="Saket sports complex"
t.write(x,font=('courier',50,'bold'))
t.penup()
t.goto(-250,100)
t.pendown()
t.color('black')
y="'taking sports to a next level'"
t.write(y,font=('courier',20,'italic'))
t.hideturtle()
t.penup()
t.goto(-150,30)
t.pendown()
t.color('white')
z="Membership Card"
t.write(z,font=('courier',30,'bold'))
t.penup()
t.goto(-630,-60)
t.pendown()
t.color('blue')
t.write("Name:
{}".format(name),font=('courier',15,'italic'))
t.penup()
t.goto(150,-60)
t.pendown()
t.color('blue')
t.write("Contact number:
{}".format(cont),font=('courier',15,'italic'))
t.penup()
t.goto(-630,-120)
t.pendown()
t.color('blue')
t.write("Email address:
{}".format(email),font=('courier',15,'italic'))
t.penup()
t.goto(150,-120)
t.pendown()
t.color('blue')
t.write("Validity period:
{}".format(duration),font=('courier',15,'italic'))
turtle.done()
break
#data of 13.4.2021
state={
'Andhra Pradesh' : [ 'Amaravati' , 928664
, 7311 ] , 'Arunachal Pradesh' : [ 'Itanagar' , 16889 ,
56 ] ,
'Assam' : [ 'Dispur' , 220893 , 1118 ] ,
'Bihar' : [ 'Patna' , 286228 , 1616 ] ,
'Chhattisgarh' : [ 'Raipur' , 31167 , 400
] , 'Goa' : [ 'Panaji' , 62780 , 850 ] ,
'Gujarat' : [ 'Gandhinagar' , 353516 ,
4855 ] , 'Haryana' : [ 'Chandigarh' , 320699 , 3282 ] ,
'Himachal Pradesh' : [ 'Shimla' , 70775 ,
1124 ] , 'Jharkhand' : [ 'Ranchi' , 141750 , 1232 ] ,
'Karnataka' : [ 'Bangalore' , 1074869 ,
12941 ] , 'Kerala' : [ 'Thiruvananthapuram' , 1172882 ,
4794 ] ,
'Madhya Pradesh' : [ 'Bhopal' , 344634 ,
4221 ] , 'Maharashtra' : [ 'Mumbai' , 3458996 , 58245 ]
,
'Manipur' : [ 'Imphal' , 29514 , 376 ] ,
'Meghalaya' : [ 'Shillong' , 14300 , 151 ] ,
'Mizoram' : [ 'Aizawl' , 4655 , 12] ,
'Nagaland' : [ 'Kohima' , 12416 , 93 ] ,
'Odisha' : [ 'Bhubaneshwar' , 351302 ,
1928 ] , 'Punjab' : [ 'Chandigarh' , 276223 , 7559 ] ,
'Rajasthan' : [ 'Jaipur' , 369564 , 2951
] , 'Sikkim' : [ 'Gangtok' , 6410 , 136 ] ,
'Tamil Nadu' : [ 'Chennai' , 940145 ,
12927 ] , 'Telangana' : [ 'Hyderabad' , 332581 , 1772 ]
,
'Tripura' : [ 'Agartala' , 33805 , 394 ]
, 'Uttarakhand' : [ 'Dehradun' , 110146 , 1767 ] ,
'Uttar Pradesh' : [ 'Lucknow ' , 705619 ,
9224 ] , 'West Bengal' : [ 'Kolkata' , 619407 , 10414 ]
}
def mod(state):
print()
print('what do you want to change?\n1.number of
deaths\n2.total confirmed cases')
print()
if a==1:
st=input('enter the state name').title()
new=int(input('enter the new value:'))
print()
if st in state:
value=state[st]
value[2]=new
print('Data Updated!')
else:
print('state not found')
elif a==2:
st=input('enter the state name').title()
new=int(input('enter the new value:'))
print()
if st in state:
value=state[st]
value[1]=new
print('Data Updated!')
else:
print('state not found')
print()
return(state)
def search(state):
print()
st=input('enter the state name you want to
search:').title()
if st in state :
print('state found')
print()
print(st)
value=state[st]
print('Capital :',value[0])
print('Confirmed Cases :',value[1])
print('Death :',value[2])
#graph
x=['Confirmed Cases' , 'Death Rate']
y=[value[1],value[2]]
plt.bar(x,y)
plt.xlabel('x-axis')
plt.ylabel('y-axis')
plt.title('Graphical Representation')
plt.grid()
plt.show()
print()
def display(state):
key=[]
val1=[]
val2=[]
for x,y in state.items():
key.append(x)
val1.append(y[1])
val2.append(y[2])
while True:
print('1.Modify any previous data')
print('2.Search for any state')
print('3.Show all data')
print('4.Show dicticionary')
print('5.Exit')
print()
x=int(input('enter your choice:'))
print()
if x==1:
state = mod(state)
elif x==2:
search(state)
elif x==3:
display(state)
elif x==4:
print(state)
print()
elif x==5:
break
else:
print('enter the valid number')
Snake Game Code
def display2():
try:
import turtle
import time
import random
from playsound import playsound
import pygame
delay = 0.1
#Music selection
print("Music List:")
print("shipping lanes")
print("destination")
print("epicness")
print("Sngs by Alan Walker are as listed
below:")
print("lily")
print("darkside")
print("play")
print("ignite")
print("on my way")
print("Hymn For The Weekend")
print("umbrella-ember island")
# Score
score = 0
high_score = 0
#Snake Body
se=("square")
sc=("pink")
#music
from pygame import mixer
x=input("Enter the name of the song you want to
be played in the background(choose from the list
above):")
pygame.mixer.init()
mixer.music.load('{}.mp3'.format(x))
mixer.music.play(-1)
#Snake head
a=("square")
b=("white")
head = turtle.Turtle()
head.speed(0)
head.shape(a)
head.color(b)
head.penup()
head.goto(0,0)
head.direction = "stop"
#Snake food
c=("circle")
d=("red")
food = turtle.Turtle()
food.speed(0)
food.shape(c)
food.color(d)
food.penup()
food.goto(0,100)
segments = []
#Pen
pen = turtle.Turtle()
pen.speed(0)
pen.shape("square")
pen.color("white")
pen.penup()
pen.hideturtle()
pen.goto(0,260)
pen.write("Score: 0 High Score: 0", align =
"center",font=("Courier",24,"normal"))
#Functions
def go_up():
if head.direction != "down":
head.direction = "up"
def go_down():
if head.direction != "up":
head.direction = "down"
def go_left():
if head.direction != "right":
head.direction = "left"
def go_right():
if head.direction != "left":
head.direction = "right"
def move():
if head.direction == "up":
y = head.ycor()
head.sety(y+20)
if head.direction == "down":
y = head.ycor()
head.sety(y-20)
if head.direction == "left":
x = head.xcor()
head.setx(x-20)
if head.direction == "right":
x = head.xcor()
head.setx(x+20)
#Keyboard bindings
wn.listen()
wn.onkeypress(go_up,"Up")
wn.onkeypress(go_down,"Down")
wn.onkeypress(go_left,"Left")
wn.onkeypress(go_right,"Right")
while True:
wn.update()
#Check for a collision with the border
if head.xcor()>290 or head.xcor()<-290 or
head.ycor()>290 or head.ycor()<-290:
time.sleep(1)
head.goto(0,0)
head.direction = "stop"
delay = 0.1
if head.distance(food)<20:
# Move the food to a random spot
x = random.randint(-290,290)
y = random.randint(-290,290)
food.goto(x,y)
#Add a segmet
new_segment = turtle.Turtle()
new_segment.speed(0)
new_segment.shape(se)
new_segment.color(sc)
new_segment.penup()
segments.append(new_segment)
# Increase in Score
move()
delay = 0.1
time.sleep(delay)
wn.mainloop()
except:
mixer.music.stop()
pass
Hotel Mangement Code
#Project-'Hotel Management'
def hotelmanagement():
import random as r
x=1
def bill(rec,feed,feed1,l):
cust=input('Enter the customer name:')
ph=int(input('Enter the phone number:'))
cus=cust.title()
if cus not in rec:
print('Name not found')
return rec , feed1,l
else:
x=rec.get(cus)
print(x)
y=x.get('Room number:')
for i in x.values():
if i!=ph:
print('Wrong number entered')
return rec , feed1,l
else:
print('Charges:')
print('a.Stay per
day=Rs.750\nb.Pick and drop service=Rs.200')
print('c.Tourist Guide charge(per
day)=Rs.200')
days=int(input('Enter the days of
stay:'))
g_days=int(input('Enter the days
with guide(if not included enter 0):'))
drop=input('Pick and Drop service
is included (yes/no):')
if drop =='yes' or 'Yes':
cost=(days*750)+(g_days*200)+200
else:
cost=(days*750)+(g_days*200)
print('Amount to be pay=Rs.',cost)
print('Thank you for visiting
us!!!')
rate=int(input('Please rate our
services out of 5:'))
feedback=input('Please give your
feedback:')
del rec[cus]
feed.append(ph)
feed.append(rate)
feed.append(feedback)
feed1[cus]=feed
l.remove(y)
def phno(rec,whose):
phn=int(input('Enter the new phone number:'))
x=rec[whose]
d={'Ph number:':phn}
x.update(d)
print('Changed successfully')
return rec
def room(rec,whose,l):
old=int(input('Please confirm your old room
number:'))
print('Room available are: ',end='')
for i in range(1,11):
if (i not in l )and (old!=i):
print(i,end=',')
print()
rono=int(input('Which room do you want?'))
x=rec[whose]
d={'Room number:':rono}
x.update(d)
l.append(rono)
l.remove(old)
print('Changed successfully')
return rec,l
def book(rec,l):
detail={}
if len(l)==10:
print('Sorry, no room is available')
return (rec,l)
name=input("Enter the customer's name:")
name=name.title()
ph=int(input("Enter the customer's ph.
number:"))
while True:
r_no=r.randint(1,10)
if r_no not in l:
l.append(r_no)
break
def start2(opt,rec,l,feed,feed1,st):
x=0
if opt==1:
rec,l=book(rec,l)
print()
y_n=input('Do you want to explore
more?')
yn=y_n.title()
if yn =='Yes':
option(rec,l,x,feed,feed1,st)
elif opt==2:
print(rec)
for x,y in rec.items():
print('Customer name:',x)
for a,b in y.items():
print(a,':',b)
y_n=input('Do you want to explore
more?')
yn=y_n.title()
if yn =='Yes':
option(rec,l,x,feed,feed1,st)
elif opt==3:
rec,feed1,l=bill(rec,feed,feed1,l)
print(feed1)
y_n=input('Do you want to explore
more?')
yn=y_n.title()
if yn =='Yes':
option(rec,l,x,feed,feed1,st)
elif opt==4:
whose=input('Whose id you want to
change?')
whose=whose.title()
for a,b in rec.items():
if whose not in rec:
print('.',end='')
else:
print('Current Status:')
print('Customer
name:',whose)
x=rec.get(whose)
break
for p,q in x.items():
print(p,q)
wh=int(input('What you want to
change?(1-ph number 2-room)'))
if wh==1:
rec=phno(rec,whose)
y_n=input('Do you want to
explore more?')
yn=y_n.title()
if yn =='Yes':
option(rec,l,x,feed,feed1,st)
elif wh==2:
rec,l=(room(rec,whose,l))
y_n=input('Do you want to
explore more?')
yn=y_n.title()
if yn =='Yes':
option(rec,l,x,feed,feed1,st)
elif opt==5:
st=opt5(opt,rec,l,st,feed,feed1)
y_n=input('Do you want to explore
more?')
yn=y_n.title()
if yn =='Yes':
print('You are requested
to login again')
start_for5(st)
def opt5(opt,rec,l,st,feed,feed1):
if opt==5:
guest=input('Please type your
name first to type your complaint:')
guest=guest.title()
if guest in rec:
feed=input('Please enter
your complaint here:')
print('Your complaint has
been registered in the name of',guest)
com=guest+'-'+feed
st.append(com)
print(st)
else:
print('Only our guests can
type their complaints here.')
print('You are requested to
login again')
x=1
start_for5(st)
return (st)
def start_for5(st):
x=0
username = input("Enter username: ")
password = input("Enter password: ")
if(username=="admin" and password
=="12345"):
print('Login Successful')
print()
option(rec,l,x,feed,feed1,st)
else:
print('Account Blocked')
def start(opt,rec,l,feed,feed1,st):
if opt<5:
print('You have to login in to use this
function')
username = input("Enter username: ")
password = input("Enter password: ")
if(username=="admin" and password
=="12345"):
print('Login Successful')
print()
a=1
else:
a=0
print('Account Blocked')
if a==1:
x=0
start2(opt,rec,l,feed,feed1,st)
else:
opt5(opt,rec,l,st,feed,feed1)
def option(rec,l,x,feed,feed1,st):
print(' '*16,'Welcome To Dream Hotel !!!')
print('How can I help you?')
print()
print('1.Booking of a room')
print("2.Guest's information")
print("3.Bill")
print("4.Updating")
print("5.Complaint/Feedback")
print("6.Exit")
opt=int(input('Please enter a vaild number:'))
if x==1 and opt<5:
start(opt,rec,l,feed,feed1,st)
else:
start2(opt,rec,l,feed,feed1,st)
rec={}
l=[]
feed=[]
feed1={}
st=[]
option(rec,l,x,feed,feed1,st)
Output
Limitations
1. Active internet connection is needed
otherwise an error will raise.
2.
Data Flow Diagram
Snake Game
Membership Hotel
Form Mangement
App
display2()
Python
(Virtual
Assistant)
Pywhatkit,
webbrower
Modules to download:
1. Pygame
2. Matplotlib
3. Pywhatkit
4. SpeechRecognition
5. Pyttsx3
6. Pyaudio
7. Translate
8. Webbrower
Pre-installed Modules:
1. Turtle
2. Pyjokes
3. Wikipedia
4. datetime
Bibliography
1. www.youtube.com
2. www.pygame.org
3. Workshop on CS and Engineering by
United College of Engineering &
Research
4. NCERT Book Class11
5. Sumita Arora Book Class12