Sei sulla pagina 1di 41

KENDRIYA VIDYALAYA

C.L.R.I CHENNAI

GUESS THE NUMBER

SUBMITTED TO :
Smt.S.KIRAN
PGT COMPUTER SCIENCE

SUBMITTED BY :
DINESH BABU S
SANTHOSH A B
AMBAREESH B
[CLASS XI A]
CERTIFICATE

This is to certify that the project “GUESS THE NUMBER”


is a bonafide work, submitted in partial fulfilment as
investigatory project by Master S. Dinesh Babu for the
academic year 2018-19.

DATE :

TEACHER INCHARGE :

EXAMINER :

PRINCIPAL :
CERTIFICATE

This is to certify that the project “GUESS THE NUMBER”


is a bonafide work, submitted in partial fulfilment as
investigatory project by Master B. Ambareesh for the
academic year 2018-19.

DATE :

TEACHER INCHARGE :

EXAMINER :

PRINCIPAL :
ACKNOWLEDGEMENT

We would like to express our special thanks of gratitude to our teacher


Smt. S. Kiran as well as our principal Y. Rama Prasad who gave us the
golden opportunity to do this wonderful project which also helped us in
doing a lot of Research and we came to know about so many new
things. We are really thankful to them.
Secondly, we would also like to thank our parents and friends who
helped us a lot in finalizing this project within the limited time frame.
INDEX

Page No. Topic


06 Project Abstract
07 Source Code
37 Sample Output Screens
39 Future Enhancements
40 Bibliography
PROJECT ABSTRACT
GUESS THE NUMBER

 The computer will think of a random number and ask you


to guess it.

 The computer will tell you if each guess is too high or too
low.

 You win if you can guess the number within limited


number of chances.

 There are 3 levels of difficulty [Easy/Medium/Hard]


SOURCE CODE

import tkinter as tk
from tkinter import *
import random

global radiotop

top = tk.Tk()
top.title("Guess The Number")

dats=('''R0lGODlhwAP0AXAAACwAAAAAwAP0AYcICAj3lBn/lBkQCAgICBAIE
Aj/9wAAc73vGSEQABAAUqUQEBAAEBBjKZT/xYz37zH3lCHO7/cQEAAApVIA
YzoApUr3WikAraXWGVrW1iEAre9rQhDmjBAhGRAIGRlaMRCMUhCUGVqEx
To6KQgIITqUYxC1YxB7ShDO5iFjKYQxGQgAYzG9cxBKMQiMpd7OexDFGULe
exBK5uZK5q3mY7WtY7XmpYTWGRnvUhlCEAgAQmsAazoIlM6lnBDe1hDFpR
A6EDHmY+YZGQCtY+atQnPmQnMZEBk6WjFjGTpCa3OMGTpzIeZCIeZzIbVC
IbWlc3MQvd5KGYRSnEIQlCFzc3u9rb29nFIQUtYQ1kLvrb2UnHOMpUK9teYAS
ikIWowZEBBzY+ZCY+ZzY7VCY7VCSnO1GRBCGWPmc3OU7xnFpYRC3hmMc
zoIQhAQ795zSntaSjGM1jpCQggIjIyElBCc3t7vre+95s7vpVJCpRnmELWtELWM
CBDvGTFjnBmUxRlC3kp7nKU6KTEIWmu9czGMUjoQjGsIQoz37xDv7869SjGU
72tj3hlapeac3q1apa2cpa173uaUzms6peZ73q06pa1aczEIQkJzEGulEHvmEOatE
OZCpXMIlKVaEBClEFrv3mvF3pRC3nvF3koZEACEKRD/xYRjYwjmMbWtMbX
mUinvEHNj3kr3jBkQIWPv3kLe5hkQAMUQ75wQAEoQ72sQIe8Q7xAQcxAQxZ
wQxWsQIcUQxRAQIZRCawjm3ozmMeatMeZjpXPOEHtrKZRj3nvF3mv3xRDvcz
oIa9bmnBkAGRD3GSEAY6XFzgjFziEQjO8AlEoQa0LvSjoAa7XF7wj/1owArVL3j
AjvKRDmjCHm7/dzEJTvCAgZY6UZABD39yG93vjiJyEOQmiRgNluimyjpZFOd3
Hu7AMzdPLEhAAAA7''')
imagePath = PhotoImage(data=dats)
widgetf = Label(top, image=imagePath, bg="#ffad33")
widgetf.place(x=0, y=0)
def play1():
radiotop.destroy()
playtop = tk.Toplevel()
playtop.title("Guess The Number")

random11=random.randint(1,9)
global mistakecount
mistakecount=5

def quit():
playtop.destroy()

def show():
x=("Oops !! You are out of chances!!\nThe Correct Answer is
"+str(random11))
msg.config(text=x)
verify.config(state='disabled')

def correct():
xx=("Yesss !! You got it right\nThe Correct Answer is
"+str(random11))
msg.config(text=xx)
verify.config(state='disabled')

def hint():
hinttop=tk.Toplevel()
hinttop.title("Purchase")

Title=Label(hinttop,text="Buy\nHints",font=('Berlin Sans
FB',26),bg="black",fg='#ff9900')
Title.pack()

hint1=Button(hinttop ,text="$20",command=None,
bg='#33cc33',width=12,bd=9)
hint1.place(x=170,y=120)

hint2=Button(hinttop ,text="$40",command=None,
bg='#33cc33',width=12,bd=9)
hint2.place(x=170,y=220)

hint3=Button(hinttop ,text="$60",command=None,
bg='#33cc33',width=12,bd=9)
hint3.place(x=170,y=320)

hint1l=Label(hinttop,text="1-Hint",font=('HP
Simplified',20),bg="black",fg='#00cc99')
hint1l.place(x=40, y=120)

hint2l=Label(hinttop,text="2-Hints",font=('HP
Simplified',20),bg="black",fg='#00cc99')
hint2l.place(x=40, y=220)

hint3l=Label(hinttop,text="10-Hints",font=('HP
Simplified',20),bg="black",fg='#00cc99')
hint3l.place(x=40, y=320)
hinttop.config(background='black')
hinttop.geometry('300x400')
hinttop.resizable(False, False)
hinttop.mainloop()

ddats1=('''R0lGODlhlQFBAnAAACH5BAEAAP8ALAAAAACVAUEChwAAAGOc/2
OU/////zqM/+a1hN6Ua++9jO9rMTqE91qM7/fFOve1Ou/FpebWveale0KM7++1l
O97Me/v797e3u+thL2EWvfFrSFrzsWMa961jGuU70pztUKM/ykpSvfejNale97W1n
OEtebFjIyErc5zGSFavc6EWpRzY71zQt7enL2Me+alY95zOhkhMc7OxbVzWrWt3n
NzaxkhrYycpe/OOu8ACIQZ5oQZte/OWq2ttealOtacY5yEa+alGQhaxSF75jp73ua
1e4RK5oRKtRlSc4Te5lJzjITexUo6QhlSEBneWhneEMW9vebW1nucpRBaziFr3rVzt
Wuc9/fmpe9z5pRzjBlSUsWEQhkZEBmErQBKxRkZcxmtaxmtIUoZ5koZtUpza0pKW
t6MQgBKtXN7lK2lpUpKtRBC3s7W1pSMjFIZjIw6EBkZ5hnO5hnOrfelOoxCjL331lK
EEIwQEIwQa4x75kpKhBlSMb2ce3OlxRDv5ua9vebmWu8Qe8UQexneexneMRmlr
VI6EJSlveY6EEqtnPfWpUpK5pR7EEoQQlIQEOZjjBml5u+HvVJz+iP2Vm6Lkm7bRi
O7ryaUUeB+h7cvu+INMHtB8rVh0l179rqCWNznOMVbbh32IJk4ERG+jYpNIVYyF
/FmvpYzZWDZfu+FmY4DStMQ1dfC96RZz2xsuo4db5Muu17Ga4WbavMK9zutG/1
wovnI4XUtO2tJz6nJq9S+5q+kKS7t8JLmyZL4tf0D2x+35R5Z3sEYUFjGX7xvX+nIMzl
jxiIgnXUpGjeuyyCuixtwgSrcLCSFqzAB8L2x0/r7+efU6edexQmYzzT6712qz1/ah8
A9CdMIh2Xi4KYeaNp0z8IbBX+I5+1sgfrSCasuS+hKq3NOz/CUhjrCKk3ijHVsIpAE
ywbKBhBCgQC7dMapxrA9xuyoMIvrakv7XNAGkvBE9xBgElBGRunRcEAThBCBm
TB8mNBICi/KOCEmGmxFPyjcXqJ7uNBKjQWLqMmUIqxBcNCmaEmGluwFPyiWK
tCMuyZX1gOL0ucrwgTDgg/NBSTIOAA5ipDOqxDO7xDPMxDPdxDPuxDP/xDQA
xEQRxEQixEQzxERExERVxERmxER3xESIxESZxESqxES7zE8QgIADs=''')
imagePath = PhotoImage(data=ddats1)
widgetf1 = Label(playtop, image=imagePath, bg="black")
widgetf1.place(x=490, y=2)
Title=Label(playtop,text="GUESS THE NUMBER(1-10)",font=('Goudy
Stout',26),bg="black",fg='#ff9900')
Title.place(x=20, y=70)
guesslabel= Label(playtop,text="What's Your Guess?",font=('Courier
New',24),bg="black",fg='white')
guesslabel.place(x=20,y=170)

inputbox=Text(playtop, height =0, width=10,


wrap=WORD,bd=5,font=("Comic Sans MS",30),bg="black",fg='white')
inputbox.place(x=20,y=210)

mistakeclabel= Label(playtop,text=('Chances Left:5'),font=('Courier


New',20),bd=11,bg="black",fg='white')
mistakeclabel.place(x=10,y=290)

msg=Label(playtop,text='',font=("Courier New", 20),bg="black",fg='white')


msg.place(x=10,y=340)

exit1=Button(playtop ,text="Quit",command=quit,height =3,


bg='#33cc33',width=25,bd=9)
exit1.place(x=20,y=410)

pa=Button(playtop ,text="Hint",command=hint,height=3,width=25,
bg='#ff0000',bd=9,fg="#ffffff")
pa.place(x=240,y=410)

def verify1():
msg.config(text='')
guess=inputbox.get("1.0",'end')
global mistakecount
if mistakecount>1:
if int(guess)>random11 :
mistakecount-=1
ddats1=None
inputbox.delete('1.0', END)
inputbox.insert('1.0','')
msg.config(text="Your guess is greater than the number")
mistakeclabel.config(text='Chances Left:'+
str(mistakecount))

elif int(guess)<random11:
mistakecount-=1
inputbox.delete('1.0', END)
inputbox.insert('1.0','')
msg.config(text="Your guess is smaller than the number")
mistakeclabel.config(text='Chances:'+str(mistakecount))

elif int(guess)==random11:
mistakecount-=1
inputbox.delete('1.0', END)
inputbox.insert('1.0','')
msg.config(text="Yesss !! You got it right")
inputbox.config(state="disabled")
mistakeclabel.config(text='Chances
Left:'+str(mistakecount))
else:
mistakecount=0
mistakeclabel.config(text='Chances:'+str(mistakecount))
msg.config(text="Oops !! You are out of chances!!")
pa.config(state="normal")
verify.config(state='disabled')
if int(guess)==random11:
msg.config(text="Yesss !! You got it right")
if int(guess)==random11:
verify.config(state='disabled')
inputbox.config(state="disabled")

def verify(event):
msg.config(text='')
guess=inputbox.get("1.0",'end')
global mistakecount
if mistakecount>1:
if int(guess)>random11 :
mistakecount-=1
inputbox.delete('1.0', END)
inputbox.insert('1.0','')
msg.config(text="Your guess is greater than the number")
mistakeclabel.config(text='Chances
Left:'+str(mistakecount))

elif int(guess)<random11:
mistakecount-=1
inputbox.delete('1.0', END)
inputbox.insert('1.0','')
msg.config(text="Your guess is smaller than the number")
mistakeclabel.config(text='Chances:'+str(mistakecount))
elif int(guess)==random11:
mistakecount-=1
inputbox.delete('1.0', END)
inputbox.insert('1.0','')
msg.config(text="Yesss !! You got it right :)")
correct()
inputbox.config(state="disabled")
mistakeclabel.config(text='Chances
Left:'+str(mistakecount))
else:
mistakecount=0
mistakeclabel.config(text='Chances:'+str(mistakecount))
msg.config(text="Oops !! You are out of chances!!")
verify.config(state='disabled')
pa.config(state="normal")
show()
if int(guess)==random11:
verify.config(state='disabled' )
if int(guess)==random11:
msg.config(text="Yesss !! You got it right :)")
verify.config(state='disabled')
correct()
inputbox.config(state="disabled")

playtop.bind('<Return>',verify)
verify=Button(playtop,text="Verify",command=verify1, height =3,
width=11,bd=7.5)
verify.place(x=290,y=210)

playtop.config(background='black')
playtop.geometry('960x500')
playtop.resizable(False, False)
playtop.mainloop()

def play2():
radiotop.destroy()
playtoplvl2 = tk.Toplevel()
playtoplvl2.title("guess The Number")

random11=random.randint(10,99)
global mistakecount11
mistakecount11=15

def quit():
playtoplvl2.destroy()

def show():
x=("Oops !! You are out of chances!!\nThe Correct Answer is
"+str(random))
msg11.config(text=x)
verify.config(state='disabled')
def correct():
xx=("Yesss !! You got it right\nThe Correct Answer is
"+str(random11))
msg11.config(text=xx)
verify.config(state='disabled')
def hint():
hinttop=tk.Toplevel()
hinttop.title("Purchase")

Title=Label(hinttop,text="Buy\nHints",font=('Berlin Sans
FB',26),bg="black",fg='#ff9900')
Title.pack()

hint1=Button(hinttop ,text="$20",command=None,
bg='#33cc33',width=12,bd=9)
hint1.place(x=170,y=120)

hint2=Button(hinttop ,text="$40",command=None,
bg='#33cc33',width=12,bd=9)
hint2.place(x=170,y=220)

hint3=Button(hinttop ,text="$60",command=None,
bg='#33cc33',width=12,bd=9)
hint3.place(x=170,y=320)

hint1l=Label(hinttop,text="1-Hint",font=('HP
Simplified',20),bg="black",fg='#00cc99')
hint1l.place(x=40, y=120)
hint2l=Label(hinttop,text="2-Hints",font=('HP
Simplified',20),bg="black",fg='#00cc99')
hint2l.place(x=40, y=220)

hint3l=Label(hinttop,text="10-Hints",font=('HP
Simplified',20),bg="black",fg='#00cc99')
hint3l.place(x=40, y=320)

hinttop.config(background='black')
hinttop.geometry('300x400')
hinttop.resizable(False, False)
hinttop.mainloop()

ddats1=('''R0lGODlhlQFBAnAAACH5BAEAAP8ALAAAAACVAUEChwAAAGOc/2
OU/////zqM/+a1hN6Ua++9jO9rMTqE91qM7/fFOve1Ou/FpebWveale0KM7++1l
O97Me/v797e3u+thL2EWvfFrSFrzsWMa961jGuU70pztUKM/ykpSvfejNale97W1n
OEtebFjIyErc5zGSFavc6EWpRzY71zQt7enL2Me+alY95zOhkhMc7OxbVzWrWt3n
NzaxkhrYycpe/OOu8ACIQZ5oQZte/OWq2ttealOtacY5yEa+alGQhaxSF75jp73ua
1e4RK5oRKtRlSc4Te5lJzjITexUo6QhlSEBneWhneEMW9vebW1nucpRBaziFr3rVzt
Wuc9/fmpe9z5pRzjBlSUsWEQhkZEBmErQBKxRkZcxmtaxmtIUoZ5koZtUpza0pKW
t6MQgBKtXN7lK2lpUpKtRBC3s7W1pSMjFIZjIw6EBkZ5hnO5hnOrfelOoxCjL331lK
EEIwQEIwQa4x75kpKhBlSMb2ce3OlxRDv5ua9vebmWu8Qe8UQexneexneMRmlr
VI6EJSlveY6EEqtnPfWpUpK5pR7EEoQQlIQEOZjjBml5u+15sVCEJTmQkq1QpTm
EEq1EIxCY5R7Qr1CQr1je0oZY4St5ow6Qkp73hBj3qXvnFKEQowQQqXOc1JaQhn
vrebvGVJaEObOGYwQjN61nCkhOuYQMYxaEEq15kp770rm7+8xeyFKrcUxe706
5r06tUqtc0q1xUrmxb0Q5r0QtZStQkrmQuZjtZStEErmEL1j5uY6QlKM1sUQOnPmE
rmnHPmc0rmcxmMWhmMEJyle9allOZaY7XmQmu1QrXmEGu1EHOte4xaQuaMY
6XFnKXvc7XW5lKMvc4QCO865u86te8Q5u8QtbWtQmvmQuaEtbWtEGvmEL2E5
ubv1hmMexmMMeaMewharda1e7XWvSFjpRkAQlKc3lqM/fZIXH8swvVfbzJAV1D
wjx2hktaa0zX5gvW4KFr9PhagANy0Ygl2GzOJu4WyrhCXzbnNNFk6TswWsPAPOj
dqU9h0GlCXU6DZ7m2jLV7SMBqVULVInonrUCLXysirGcJt9y9qCtksszc1bzp9s8nT
6WbywIkQz+6Va0RC5m7uwkif3MrVNDKIZKYr2q+OicILs4RVjyVvik1HmnEq3LV
hJxfDiKI8V29SIFcsOvMR7qRVC0JTpRlPYeMcrqjSN5bSZU5oDm2yyUCEoXayVsZIr
swp0alc7jv8Fl1U8ehX7mctbXY8A33xzq6D/HvVJz+iP2Vm6Lkm7bRiO7ryaUUeB+
h7cvu+INMHtB8rVh0l179rqCWNznOMVbbh32IJk4ERG+jYpNIVYyF/FmvpYzZW
DZfu+FmY4D==''')
imagePath = PhotoImage(data=ddats1)
widgetf1 = Label(playtoplvl2, image=imagePath, bg="black")
widgetf1.place(x=490, y=2)

Title=Label(playtoplvl2,text="Guess THE NUMBER(10-100)",font=('Goudy


Stout',26),bg="black",fg='#ff9900')
Title.place(x=20, y=70)

guess11label= Label(playtoplvl2,text="What's Your Guess?",font=('Courier


New',24),bg="black",fg='white')
guess11label.place(x=20,y=170)

inputbox11=Text(playtoplvl2, height =0, width=10,


wrap=WORD,bd=5,font=("Comic Sans MS",30),bg="black",fg='white')
inputbox11.place(x=20,y=210)

mistakeclabel11= Label(playtoplvl2,text=('Chances Left:15'),font=('Courier


New',20),bd=11,bg="black",fg='white')
mistakeclabel11.place(x=10,y=290)

msg11=Label(playtoplvl2,text='',font=("Courier New",
20),bg="black",fg='white')
msg11.place(x=10,y=340)
exit1=Button(playtoplvl2 ,text="Quit",command=quit,height =3,
bg='#33cc33',width=25,bd=9)
exit1.place(x=20,y=410)
pa=Button(playtoplvl2 ,text="Hint",command=hint,height
=3,width=25,bg='#ff0000',bd=9,fg="#ffffff")
pa.place(x=240,y=410)
def verify1():
msg11.config(text='')
guess11=inputbox11.get("1.0",'end')
global mistakecount11
if mistakecount11>1:
if int(guess11)>random11 :
mistakecount11-=1
ddats1=None
inputbox11.delete('1.0', END)
inputbox11.insert('1.0','')
msg11.config(text="Your guess is greater than the
number")
mistakeclabel11.config(text='Chances
Left:'+str(mistakecount11))

elif int(guess11)<random11:
mistakecount11-=1
inputbox11.delete('1.0', END)
inputbox11.insert('1.0','')
msg11.config(text="Your guess is smaller than the
number")

mistakeclabel11.config(text='Chances:'+str
(mistakecount11))

elif int(guess11)==random11:
mistakecount11-=1
inputbox11.delete('1.0', END)
inputbox11.insert('1.0','')
msg11.config(text="Yesss !! You got it right")
correct()
inputbox11.config(state="disabled")
mistakeclabel11.config(text='Chances
Left:'+str(mistakecount11))
else:
mistakecount11=0
mistakeclabel11.config(text='Chances:'+str(mistakecount11))
msg11.config(text="Oops !! You are out of chances!!")
pa.config(state="normal")
verify.config(state='disabled')
if int(guess11)==random11:
msg11.config(text="Yesss !! You got it right")
correct()

inputbox11.config(state="disabled")

def verify(event):
msg11.config(text='')
guess11=inputbox11.get("1.0",'end')
global mistakecount11
if mistakecount11>1:
if int(guess11)>random11 :
mistakecount11-=1
inputbox11.delete('1.0', END)
inputbox11.insert('1.0','')
msg11.config(text="Your guess is greater than the
number")
mistakeclabel11.config(text='Chances
Left:'+str(mistakecount11))

elif int(guess11)<random11:
mistakecount11-=1
inputbox11.delete('1.0', END)
inputbox11.insert('1.0','')
msg11.config(text="Your guess is smaller than the number
")

mistakeclabel11.config(text='Chances:'+str(mistakecount11))

elif int(guess11)==random11:
mistakecount11-=1
inputbox11.delete('1.0', END)
inputbox11.insert('1.0','')
msg11.config(text="Yesss !! You got it right")
correct()
inputbox11.config(state="disabled")
mistakeclabel11.config(text='Chances
Left:'+str(mistakecount11))
else:
mistakecount11=0
if mistakecount11==0:

mistakeclabel11.config(text='Chances:'+str(mistakecount11))
msg11.config(text="Oops !! You are out of chances!!")
pa.config(state="normal")
show()
verify.config(state='disabled')
if int(guess11)==random11:
msg11.config(text="Yesss !! You got it right")
verify.config(state='disabled')
correct()

inputbox11.config(state="disabled")

playtoplvl2.bind('<Return>',verify)

verify=Button(playtoplvl2,text="Verify",command=verify1, height =3,


width=11,bd=7.5)
verify.place(x=290,y=210)

playtoplvl2.config(background='black')
playtoplvl2.geometry('960x500')
playtoplvl2.resizable(False, False)
playtoplvl2.mainloop()
def play3():
radiotop.destroy()
playtoplvl3 = tk.Toplevel()
playtoplvl3.title("Guess The Number")

random1=random.randint(99,999)
global mistakecount11
mistakecount11=20

def quit():
playtoplvl3.destroy()

def show():
x=("Oops !! You are out of chances!!\nThe Correct Answer is
"+str(random1))
msg11.config(text=x)
verify.config(state='disabled')

def correct():
xx=("Yesss !! You got it right\nThe Correct Answer is "+str(random1))
msg11.config(text=xx)
verify.config(state='disabled')
def hint():
hinttop=tk.Toplevel()
hinttop.title("Purchase")
Title=Label(hinttop,text="Buy\nHints",font=('Berlin Sans
FB',26),bg="black",fg='#ff9900')
Title.pack()
hint1=Button(hinttop ,text="$20",command=None,
bg='#33cc33',width=12,bd=9)
hint1.place(x=170,y=120)

hint2=Button(hinttop ,text="$40",command=None,
bg='#33cc33',width=12,bd=9)
hint2.place(x=170,y=220)

hint3=Button(hinttop ,text="$60",command=None,
bg='#33cc33',width=12,bd=9)
hint3.place(x=170,y=320)

hint1l=Label(hinttop,text="1-Hint",font=('HP
Simplified',20),bg="black",fg='#00cc99')
hint1l.place(x=40, y=120)

hint2l=Label(hinttop,text="2-Hints",font=('HP
Simplified',20),bg="black",fg='#00cc99')
hint2l.place(x=40, y=220)

hint3l=Label(hinttop,text="10-Hints",font=('HP
Simplified',20),bg="black",fg='#00cc99')
hint3l.place(x=40, y=320)
hinttop.config(background='black')
hinttop.geometry('300x400')
hinttop.resizable(False, False)
hinttop.mainloop()

ddats1=('''R0lGODlhlQFBAnAAACH5BAEAAP8ALAAAAACVAUEChwAAAGOc/2
OU/////zqM/+a1hN6Ua++9jO9rMTqE91qM7/fFOve1Ou/FpebWveale0KM7++1l
O97Me/v797e3u+thL2EWvfFrSFrzsWMa961jGuU70pztUKM/ykpSvfejNale97W1n
OEtebFjIyErc5zGSFavc6EWpRzY71zQt7enL2Me+alY95zOhkhMc7OxbVzWrWt3n
NzaxkhrYycpe/OOu8ACIQZ5oQZte/OWq2ttealOtacY5yEa+alGQhaxSF75jp73ua
1e4RK5oRKtRlSc4Te5lJzjITexUo6QhlSEBneWhneEMW9vebW1nucpRBaziFr3rVzt
Wuc9/+6Va0RC5m7uwkif3MrVNDKIZKYr2q+OicILs4RVjyVvik1HmnEq3LVhJxfDi
KI8V29SIFcsOvMR7qRVC0JTpRlPYeMcrqjSN5bSZU5oDm2yyUCEoXayVsZIrswp0
alc7jv8Fl1U8ehX7mctbXY8A33xzq6D/HvVJz+iP2Vm6Lkm7bRiO7ryaUUeB+h7cvu
+INMHtB8rVh0l179rqCWNznOMVbbh32IJk4ERG+jYpNIVYyF/FmvpYzZWDZfu+F
mY4DStMQ1dfC96RZz2xsuo4db5Muu17Ga4WbavMK9zutG/1wovnI4XUtO2tJz6nJ
q9S+5q+kKS7t8JLmyZL4tf0D2x+35R5Z3sEYUFjGX7xvX+nIMzljxiIgnXUpGjeuyyC
uixtwgSrcLCSFqzAB8L2x0/r7+efU6edexQmYzzT6712qz1/ah8A9CdMIh2Xi4KYea
Np0z8IbBX+I5+1sgfrSCasuS+hKq3NOz/CUhjrCKk3ijHVsIpAEywbKBhBCgQC7d
MapxrA9xuyoMIvrakv7XNAGkvBE9xBgElBGRunRcEAThBCBmTB8mNBICi/KOCE
mGmxFPyjcXqJ7uNBKjQWLqMmUIqxBcNCmaEmGluwFPyiWKtCMuyZX1gOL0uc
rwgTDgg/NBSTIOAA5ipDOqxDO7xDPMxDPdxDPuxDP/xDQAxEQRxEQixEQzxE
RExERVxERmxER3xESIxESZxESqxES7zE8QgIADs=''')
imagePath = PhotoImage(data=ddats1)
widgetf1 = Label(playtoplvl3, image=imagePath, bg="black")
widgetf1.place(x=490, y=2)

Title=Label(playtoplvl3,text="Guess THE NUMBER(100-


1000)",font=('Goudy Stout',26),bg="black",fg='#ff9900')
Title.place(x=20, y=70)

guess111label= Label(playtoplvl3,text="What's Your


Guess?",font=('Courier New',24),bg="black",fg='white')
guess111label.place(x=20,y=170)

inputbox11=Text(playtoplvl3, height =0, width=10,


wrap=WORD,bd=5,font=("Comic Sans MS",30),bg="black",fg='white')
inputbox11.place(x=20,y=210)

mistakeclabel11= Label(playtoplvl3,text=('Chances Left:20'),font=('Courier


New',20),bd=11,bg="black",fg='white')
mistakeclabel11.place(x=10,y=290)

msg11=Label(playtoplvl3,text='',font=("Courier New",
20),bg="black",fg='white')
msg11.place(x=10,y=340)

exit11=Button(playtoplvl3 ,text="Quit",command=quit,height =3,


bg='#33cc33',width=25,bd=9)
exit11.place(x=20,y=410)

pa=Button(playtoplvl3 ,text="Hint",command=hint,height
=3,width=25,bg='#ff0000',bd=9,fg="#ffffff")
pa.place(x=240,y=410)

def verify1():
msg11.config(text='')
guess11=inputbox11.get("1.0",'end')
global mistakecount11
if mistakecount11>1:
if int(guess11)>random1 :
mistakecount11-=1
ddats1=None
inputbox11.delete('1.0', END)
inputbox11.insert('1.0','')
msg11.config(text="Your guess is greater than the
number")
mistakeclabel11.config(text='Chances
Left:'+str(mistakecount11))
elif int(guess11)<random1:
mistakecount11-=1
inputbox11.delete('1.0', END)
inputbox11.insert('1.0','')
msg11.config(text="Your guess is smaller than the
number")

mistakeclabel11.config(text='Chances:'+str(mistakecount11))

elif int(guess11)==random1:
mistakecount11-=1
inputbox11.delete('1.0', END)
inputbox11.insert('1.0','')
msg11.config(text="Yesss !! You got it right")
correct()
inputbox11.config(state="disabled")
mistakeclabel11.config(text='Chances
Left:'+str(mistakecount11))
else:
mistakecount11=0
mistakeclabel11.config(text='Chances:'+str(mistakecount11))
msg11.config(text="Oops !! You are out of chances!!")
pa.config(state="normal")
verify.config(state='disabled')
if int(guess11)==random1:
msg11.config(text="Yesss !! You got it right")
correct()

inputbox11.config(state="disabled")

def verify(event):
msg11.config(text='')
guess11=inputbox11.get("1.0",'end')
global mistakecount11
if mistakecount11>1:
if int(guess11)>random1 :
mistakecount11-=1
inputbox11.delete('1.0', END)
inputbox11.insert('1.0','')
msg11.config(text="Your guess is greater than the
number")
mistakeclabel11.config(text='Chances
Left:'+str(mistakecount11))

elif int(guess11)<random1:
mistakecount11-=1
inputbox11.delete('1.0', END)
inputbox11.insert('1.0','')
msg11.config(text="Your guess is smaller than the
number ")

mistakeclabel11.config(text='Chances:'+str(mistakecount11))

elif int(guess11)==random1:
mistakecount11-=1
inputbox11.delete('1.0', END)
inputbox11.insert('1.0','')
msg11.config(text="Yesss !! You got it right")
correct()
inputbox11.config(state="disabled")
mistakeclabel11.config(text='Chances
Left:'+str(mistakecount11))
else:
mistakecount11=0
if mistakecount11==0:
mistakeclabel11.config(text='Chances:’
+str(mistakecount11))
msg11.config(text="Oops !! You are out of chances!!")
pa.config(state="normal")
show()
verify.config(state='disabled')
if int(guess11)==random1:
msg11.config(text="Yesss !! You got it right")
verify.config(state='disabled')
correct()
inputbox11.config(state="disabled")

playtoplvl3.bind('<Return>',verify)

verify=Button(playtoplvl3,text="Verify",command=verify1, height =3,


width=11,bd=7.5)
verify.place(x=290,y=210)
playtoplvl3.config(background='black')
playtoplvl3.geometry('960x500')
playtoplvl3.resizable(False, False)
playtoplvl3.mainloop()

def selecter():
global radiotop
radiotop=Tk()
radiotop.title("Level?")
label1 = Label( radiotop, text="\nSELECT LEVEL")
label1.config(font=("Comic Sans MS",15))
label1.pack()

try:
def playlvl1():
play1()

def playlvl2():
play2()
def playlvl3():
play3()

var = StringVar(value="1")

note = Radiobutton(radiotop, text="Easy",width = 20,padx =


20,indicatoron = 0, variable=var, value="Easy",command=(playlvl1))
note.place(x=10,y=70)
word = Radiobutton(radiotop, text="Medium",width = 20,padx =
20,indicatoron = 0, variable=var,
value="Medium",command=playlvl2)
word.place(x=10,y=100)

ppt = Radiobutton(radiotop, text="Hard",width = 20,padx =


20,indicatoron = 0, variable=var, value="Hard",command=playlvl3)
ppt.place(x=10,y=130)

radiotop.resizable(False, False)
radiotop.geometry("210x220")
radiotop.mainloop()

except:
print("error in selector")

def quit():
top.destroy()

def instructions():
instop = tk.Toplevel()
instop.title("Guess The Number")

widgetf1 = Label(instop, text="RULES\n\nSelect the difficulty


level.[Easy/Medium/Hard]\nA random number is generated for you to
guess.\nYour objective is to guess the number \nwith the help of the given
clues.\
\n\nEASY :\n>A number between 1-10 is generated.\n>You have 5 chances to
guess the number.\
\n\nMEDIUM :\n>A number between 10-100 is generated.\n>You have 15
chances to guess the number.\
\n\nHARD :\n>A number between 100-1000 is generated.\n>You have 20
chances to guess the number."
,bg="#4dff88",font=("Trebuchet MS",16))
widgetf1.pack()

instop.config(background='black')
instop.geometry('480x490')
instop.resizable(False, False)
instop.mainloop()

def credits():
crdtop = tk.Toplevel()
crdtop.title("Credits")

widgetf2 = Label(crdtop,
text="CREDITS",bg="#004d26",font=("Rockwell",26),fg="#80ff00")
widgetf2.pack()
widgetf3 = Label(crdtop, text = "
PRODUCERS",bg="#004d26",font=("Rockwell",18),fg="#80ff00")
widgetf3.pack()
widgetf3.place(x=20,y=90)
widgetf4 = Label(crdtop, text = "Babu &
Co.",bg="#004d26",font=("Rockwell",18),fg="#80ff00")
widgetf4.pack()
widgetf4.place(x=400,y=90)
widgetf4 = Label(crdtop, text =
":",bg="#004d26",font=("Rockwell",18),fg="#80ff00")
widgetf4.pack()
widgetf4.place(x=320,y=90)

widgetf5 = Label(crdtop, text =


"DESIGNERS",bg="#004d26",font=("Rockwell",18),fg="#80ff00")
widgetf5.pack()
widgetf5.place(x=20,y=150)

widgetf6 = Label(crdtop, text =


":",bg="#004d26",font=("Rockwell",18),fg="#80ff00")
widgetf6.pack()
widgetf6.place(x=320,y=150)
widgetf7 = Label(crdtop, text = "The
Pythonist",bg="#004d26",font=("Rockwell",18),fg="#80ff00")
widgetf7.pack()
widgetf7.place(x=400,y=150)

widgetf8 = Label(crdtop, text =


"PROGRAMMERS",bg="#004d26",font=("Rockwell",18),fg="#80ff00")
widgetf8.pack()
widgetf8.place(x=20,y=210)

widgetf9 = Label(crdtop, text =


":",bg="#004d26",font=("Rockwell",18),fg="#80ff00")
widgetf9.pack()
widgetf9.place(x=320,y=210)

widgetf10 = Label(crdtop, text = "Ambareesh B\nDinesh Babu


S",bg="#004d26",font=("Rockwell",18),fg="#80ff00")
widgetf10.pack()
widgetf10.place(x=390,y=210)

widgetf11 = Label(crdtop, text = "SPECIAL


THANKS",bg="#004d26",font=("Rockwell",18),fg="#80ff00")
widgetf11.pack()
widgetf11.place(x=20,y=270)

widgetf12 = Label(crdtop, text =


":",bg="#004d26",font=("Rockwell",18),fg="#80ff00")
widgetf12.pack()
widgetf12.place(x=320,y=270)

widgetf13 = Label(crdtop, text = "Smt. S. Kiran\n [PGT Comp.


Sci.]",bg="#004d26",font=("Rockwell",18),fg="#80ff00")
widgetf13.pack()
widgetf13.place(x=350,y=270)

widgetf14 = Label(crdtop, text = "Santhosh [The


Pythonist]",bg="#004d26",font=("Rockwell",18),fg="#80ff00")
widgetf14.pack()
widgetf14.place(x=390,y=335)

widgetf15 = Label(crdtop, text = "Our Parents & Friends


<3",bg="#004d26",font=("Rockwell",18),fg="#80ff00")
widgetf15.pack()
widgetf15.place(x=390,y=370)

crdtop.config(bg="#004d26")
crdtop.geometry('685x460')
crdtop.resizable(False, False)
crdtop.mainloop()

play=Button(top,text="Play",command=selecter,height =3,
width=25,bg='#ff0000',bd=9,fg="#ffffff")
play.place(x=50,y=377)

help=Button(top ,text="How to play",command=instructions,height


=3,bg="#ffff00", width=25,bd=9)
help.place(x=270,y=377)

credits=Button(top,text="Credits",command=credits,height =3,
bg="#6699ff",width=25,bd=9)
credits.place(x=490,y=377)

exit=Button(top ,text="Quit",command=quit,height =3,


bg='#33cc33',width=25,bd=9)
exit.place(x=710,y=377)

top.config(background='black')
top.geometry('960x500')
top.resizable(False, False)
top.mainloop()
SAMPLE OUTPUT SCREENS
FUTURE ENHANCEMENTS

 The interface of the game will be improved.

Credit points will be added as a feature.

In-app purchases will be made available for the


users to buy hints.

More interesting modes of gameplay will be made


available in the future updates.
BIBLIOGRAPHY

 GUI REFERENCES
https://wiki.python.org/moin/TkInter
https://www.tutorialspoint.com/python/python_gui_progra
mming.htm

 CONCEPTUAL REFERENCES
https://www.python.org/
https://inventwithpython.com/chapter4.html
https://www.slideshare.net/
https://www.youtube.com/?reload=9
CONCLUSION

1. The game “Guess the number” tests and


enhances the users' analytical skills.
2. This game has user-friendly interface and is
easy to play.
3. It involves high thinking ability and a lot of
fun as well.
4. There’ll be a beta version of the game
“Guess the number” in which the users can
view and edit the game-code, which in turn
improves their coding skills.

Potrebbero piacerti anche