Professional Documents
Culture Documents
KALIN ROZARIO.S
Roll no: 7215
12 B
VIDYA MANDIR @ ESTANCIA SCHOOL
Page 1 of 27
ACKNOWLEDGEMENT
I would like to thank our school principal, Mrs.Sankari Ravi, and the school
management for the support they have offered me.
I would also like to thank my family and friends, who helped me collect the needed
information for the project. Their valuable suggestions and guidance have been
helpful in various phases of the completion of the project.
Last but not the least, I would like to thank my teammates, Vishwaswaroop and
Jothimadhavann, for their enthusiastic support and hard work in making this project.
Page 2 of 27
TABLE OF CONTENTS:
1. Introduction 4
2. Concepts used 6
3. Source Code 7
4. Output 22
5. Conclusion 26
6. Future development 26
7. Bibliography 27
Page 3 of 27
INTRODUCTION
Python is an interpreted high-level general-purpose programming language. It
supports multiple programming paradigms, including structured, object-oriented,
and functional programming. It was created by Guido Van Rossum in February
1991. It is based on two programming languages:
● ABC language
● Module-3
Hardware used
Page 4 of 27
Software used
● Operating System: Processors: Intel® Core™ i5 processor 4300M at 2.60
GHz or 2.59 GHz (1 socket, 2 cores, 2 threads per core)
● Operating systems: Windows* 7 or later, macOS, and Linux
● Python* versions: 2.7.X, 3.6.X or 3.9.X
How to install:
To play the game without any issues, you need to install our program into the
folder where python generally saves your code.
If the game still doesn’t work properly, try installing the program in the folder
where you installed Python.
To access the folder where Python is installed, right-click on the Python IDLE
icon and select “Open file location”.
Page 5 of 27
CONCEPTS USED
BUILT-IN FUNCTIONS:
MODULES:
Page 6 of 27
SOURCE CODE:
int_var = IntVar()
Page 7 of 27
inputtxt2_var = StringVar()
more_than = "Your number is more than the mystery number!"
less_than = "Your number is less than the mystery number!"
correct = "You Guessed it right!!!!!"
not_valid = "Enter a valid number!!"
out_of = "You are out of guesses. GAME OVER"
sports = ['rugby', 'hockey', 'squash', 'golf', 'football', 'vallam kali', 'basketball',
'cricket']
fruits_vegetables = ['grapes', 'watermelon', 'raisin', 'onion', 'mushroom']
games = ['chess', 'monopoly', 'carrom', 'scrabble']
chess_ch = "A horse jumps over a tower and the tower disappears. it's not an
illusion or a dream. where could this happen? "
monopoly_ch = "The aim of the game is to have the most properties and most
money at the end. the mascot is a guy with a black hat."
carrom_ch = "you put the coins in the pocket. if its yours, you take it. otherwise
you give it. what game is this?"
scrabble_ch = "Put down the words cleverly and get more points. what game is
this?"
rugby_ch = "phrase related to the sport: That is a touchdown!!!! [HARD]"
hockey_ch = "Involves hitting a disk into a net to score [MEDIUM]"
squash_ch = " racket and ball sport played by two players in a four-walled court
with a small, hollow rubber ball [HARD]"
vallam_kali_ch = "this sport is celebrated in Kerala on the festive occasion of
Onam. involves boats [IMPOSSIBLE]"
golf_ch = "objective: to hit a small ball into a small hole. words related to the
sport: Par, Birdie, Bogey [HARD]"
football_ch = "Two teams try to hit a ball in the opponents net. only legs are used
[EASY]"
Page 8 of 27
basketball_ch = "Players are usually very tall and can jump high [MEDIUM]"
cricket_ch = "The name of the sport is derived from the Middle Dutch word
*kricke* [Easy]"
grapes_ch = "I can be red or green and I grow on a vine. I'm dried to make raisins,
or squeezed to make wine. What am I?"
watermelon_ch = "I look green but what you eat is red, and what you spit out is
black. What am I?"
raisin_ch = "I'm wrinkled and people treat me in a different way: they chew or pick
out and throw away. What am I?"
onion_ch = "You cut me, chop me, dice me and cry over me. What am I?"
mushroom_ch = "I'm a room that you can eat. What am I?"
def save_point():
global point
global str_point
if
os.path.exists('C:\\Users\\admin\\AppData\\Local\\Programs\\Python\\Python39\\p
oint.txt'):
os.chmod("point.txt", S_IRUSR | S_IWUSR | S_IXUSR)
with open("point.txt", 'r') as p:
score = p.read()
with open("point.txt", 'w') as p:
record = int(score)
record+=point
win_count = str(record)
x = p.write(win_count)
points_var.set(record)
point = 0
Page 9 of 27
else:
with open("point.txt", 'w') as p:
os.chmod("point.txt", S_IRUSR | S_IWUSR | S_IXUSR)
x = p.write(str_point)
points_var.set(point)
def ask_for_save():
msg = messagebox.askquestion("SAVE", "Do you want to save the file?", icon =
'question')
if msg == 'yes':
save_point()
else:
messagebox.showinfo('RETURN',"Click the SAVE button when you wish to
save your win count")
def sport_guessing():
if guess_No != 0:
if random_sport == "rugby":
message_var.set(rugby_ch)
elif random_sport == "hockey":
message_var.set(hockey_ch)
elif random_sport == "squash":
message_var.set(squash_ch)
elif random_sport == "vallam kali":
message_var.set(vallam_kali_ch)
elif random_sport == "golf":
Page 10 of 27
message_var.set(golf_ch)
elif random_sport == "football":
message_var.set(football_ch)
elif random_sport == "basketball":
message_var.set(basketball_ch)
elif random_sport == "cricket":
message_var.set(cricket_ch)
elif guess_No == 0:
message_var.set("You are out of guesses. GAME OVER!")
def fruitveg_guessing():
if guess_No != 0:
if random_fruitveg == "grapes":
message_var.set(grapes_ch)
elif random_fruitveg == "watermelon":
message_var.set(watermelon_ch)
elif random_fruitveg == "raisin":
message_var.set(raisin_ch)
elif random_fruitveg == "onion":
message_var.set(onion_ch)
elif random_fruitveg == "mushroom":
message_var.set(mushroom_ch)
elif guess_No == 0:
message_var.set("You are out of guesses. GAME OVER!")
Page 11 of 27
def game_guessing():
global guess_No
if guess_No != 0:
if random_game == "chess":
message_var.set(chess_ch)
elif random_game == "monopoly":
message_var.set(monopoly_ch)
elif random_game == "carrom":
message_var.set(carrom_ch)
elif random_game == "scrabble":
message_var.set(scrabble_ch)
elif guess_No == 0:
message_var.set("You are out of guesses. GAME OVER!")
def sport_checking():
global guess_No
global point
word = inputtxt2_var.get()
if guess_No != 0:
if word.lower() == random_sport:
prompt_var.set("You guessed it right!!!")
point += 1
else:
prompt_var.set("WRONG!!")
guess_No = guess_No - 1
Page 12 of 27
elif guess_No == 0:
prompt_var.set("You are out of guesses. GAME OVER!")
def fruitveg_checking():
global guess_No
global point
word = inputtxt2_var.get()
if guess_No != 0:
if word.lower() == random_fruitveg:
prompt_var.set("You guessed it right!!!")
point += 1
else:
prompt_var.set("WRONG!!")
guess_No = guess_No - 1
elif guess_No == 0:
prompt_var.set("You are out of guesses. GAME OVER!")
def game_checking():
global guess_No
global point
word = inputtxt2_var.get()
if guess_No != 0:
if word.lower() == random_game:
prompt_var.set("You guessed it right!!!")
Page 13 of 27
point += 1
else:
prompt_var.set("WRONG!!")
guess_No = guess_No - 1
elif guess_No == 0:
prompt_var.set("You are out of guesses. GAME OVER!")
def chck_num():
global more_than
global less_than
global correct
global not_valid
global out_of
global guess
global guess_No
global point
if guess_No != 0:
if guess > rand_number:
string_var.set(more_than)
guess_No = guess_No - 1
elif guess < rand_number:
string_var.set(less_than)
Page 14 of 27
guess_No = guess_No - 1
elif guess == rand_number:
string_var.set(correct)
point += 1
else:
string_var.set(not_valid)
elif guess_No == 0:
string_var.set(out_of)
def randguess():
global guess_No
guess_No = rd.randint(1,9)
rand = str(guess_No)
number = Label(top1, text = "No. of guesses: "+rand, font = 11). place(x = 230,
y = 230)
def open_wordguess():
global message_var
global prompt_var
global random_fruitveg
global random_sport
global random_game
top3 = Toplevel(top1)
top3.title("Word Guessing")
Page 15 of 27
top3.geometry("900x600")
random_sport = rd.choice(sports)
random_fruitveg = rd.choice(fruits_vegetables)
random_game = rd.choice(games)
alert = Label(top3, text = "Select which genre you want the word to be from
below: ", font = 12)
alert.place(x = 280, y = 150)
message_var = StringVar()
message_var.set("**The Hint will be displayed here**")
Page 16 of 27
message = Label(top3, textvariable = message_var, font = 15)
message.pack()
prompt_var = StringVar()
prompt_var.set(".")
prompt = Label(top3, textvariable = prompt_var, font = 13)
prompt.pack()
top3.resizable(False,False)
Page 17 of 27
def open_numberguess():
global rand_number
global string_var
top2 = Toplevel(top1)
top2.title("Number Guessing")
top2.geometry("700x600")
prompt = Label(top2, text = "Guess the number between 1-50", font = 12).
place(x = 220, y = 230)
string_var = StringVar()
string_var.set("hello")
Page 18 of 27
guess = enter
top2.resizable(False, False)
def input_num():
global guess
inp = int_var.get()
guess = inp
return inp
def open_guesses():
global top1
top1 = Toplevel(root)
top1.title("No. Of Guesses")
top1.geometry("600x500")
Page 19 of 27
number_btn = Button(top1, text = "Guess a Number", command =
open_numberguess). place(x = 190, y = 260)
top1.resizable(False, False)
points_var = StringVar()
points = Label(root, textvariable = points_var). place(x = 400, y = 350)
info = Label(root, text = "Your Win Count: ", font = 15). place(x = 250, y = 350)
style = Style()
Page 20 of 27
style.configure("BW.TLabel", background = "red", foreground = "white", font =
15)
quit_buttn = Button(root, text = "QUIT", style = "BW.TLabel", command =
root.destroy). place(x = 320, y = 500)
root.resizable(False, False)
root.mainloop()
Page 21 of 27
OUTPUT:
Page 22 of 27
Page 23 of 27
Page 24 of 27
Page 25 of 27
CONCLUSION:
The Number/Word guessing game is a simple yet fun game. Compete with your
friends to see who was the most wins in the game.
FUTURE DEVELOPMENT:
The scope for future developments in the program is very high. The following
developments can be made to the program:
Making calculations on the probability of random guessing numbers.
They can be used for analytical study on number theorems, sets and
relations and used in variable generating functions.
Can be used for specific purposes for captcha generation for passwords.
Page 26 of 27
BIBLIOGRAPHY
Page 27 of 27