Professional Documents
Culture Documents
GAMSTAT - NSS (SJ)
GAMSTAT - NSS (SJ)
PUDUCHERRY
Page 1 of 41
KENDRIYA VIDYALAYA NO-1, JIPMER CAMPUS
PUDUCHERRY
CERTIFICATE
This is to certify that this project is an original
work done by SUURAJ GG of class XII-A Computer
science during the academic year 2023-24 under
my guidance as per the guidelines issued by the
Central Board of Secondary Education.
PRINCIPAL
SH. JOSE MATHEW
(PRINCIPAL, KV NO-1, PUDUCHERRY)
Page 2 of 41
TABLE OF CONTENTS
1 ACKNOWLEDGEMENT 4
2 INTRODUCTION 5
3 OBJECTIVE 6
4 PROPOSED SYSTEM 7
5 FLOWCHART 8
6 SOFTWARE USED 9
7 SOURCE CODE 10
8 OUTPUT 25
9 REFERENCE 39
Page 3 of 41
ACKNOWLEDGEMENT
Suuraj GG
XII-A
Page 4 of 41
INTRODUCTION
Page 5 of 41
OBJECTIVE
Page 6 of 41
PROPOSED SYSTEM
1) Education Module:
A dedicated section for educational games like the
math quiz, where players can test their knowledge
and learn new concepts.
2) Gameplay:
Players can access and play the games directly
within the portal.
Each game should have clear rules and
instructions.
3) Game Library:
Display game information, including
title,description, and genre
Page 7 of 41
FLOWCHART
Page 8 of 41
SOFTWARE USED
➢Python(spyder)
➢Python(3.11)
➢Visual communication code
➢tkinter
Page 9 of 41
SOURCE CODE
print('''
*******************************************************************************
*******************************************************************************
:> Welcome to our GAMSTAT, where you can enjoy a variety of fun and challenging games, all created
with
Python. Whether you want to test your vocabulary with hangman, your logic with tic tac toe, your
luck with guess the number, your math skills with math quiz, or your strategy with rock paper
scissor,
we have something for everyone. Our games are easy to play, but hard to master. You can also
compete
with your friends and see who can get the highest score. So what are you waiting for? Start playing
and
have fun!...
:> Before you start every game we have been guiding you with some introduction or with some rules
to make
:> credits..
- Nandhana.K.S
- Suuraj.G.G
''')
Page 10 of 41
print(''' ( LETS GET STARTED!! )
-------------------------------------------------------------------------------------------------------------''')
n='y'
print('''
''')
if ch=='1':
print('''
''')
import random
num = random.randint(1, 5)
Page 11 of 41
guess = None
guess = int(guess)
if guess == num:
break
else:
print('''
''')
elif ch=='2':
print('''
friend and see who emerges as the ultimate Tic Tac Toe
champion!!!!
''')
# To create a GUI for a tic tac toe game in Python, we can use the tkinter module
Page 12 of 41
# First, we import tkinter and create a root window
import tkinter as tk
root = tk.Tk()
buttons = []
for i in range(3):
row = []
for j in range(3):
# Each button has a text variable that stores its value (X, O or empty)
# Each button also has a command that calls the function play when clicked
text_var = tk.StringVar()
text_var.set(" ")
button.grid(row=i, column=j)
row.append((button, text_var))
buttons.append(row)
status_var = tk.StringVar()
status_var.set("X's turn")
board = [[" ", " ", " "], [" ", " ", " "], [" ", " ", " "]] # The board as a 2D list of values
Page 13 of 41
# We define the function play that handles the logic of the game
# Update the button's text and the board's value with the current turn
buttons[row][col][1].set(turn)
board[row][col] = turn
if check_win(turn):
# Update the status label and set the game over flag to True
game_over = True
elif check_tie():
# Update the status label and set the game over flag to True
status_var.set("It's a tie!")
game_over = True
# If the game is not over yet, switch the turn and update the status label
else:
# We define the function check_win that returns True if the given player has formed a line of
three on the board
def check_win(player):
global board
for i in range(3):
return True
Page 14 of 41
# Check the columns
for j in range(3):
return True
return True
return True
return False
# We define the function check_tie that returns True if the board is full and there is no winner
def check_tie():
global board
# Loop through the board and check if there is any empty space left
for i in range(3):
for j in range(3):
return False
return True
root.mainloop()
print('''
''')
elif ch=='3':
print('''
Page 15 of 41
Rock, Paper, Scissors game is perfect for passing the time.
''')
ch='y'
import random
exit()
computer_choice = random.choice(choices)
Page 16 of 41
print(f"You chose {user_choice}.")
if user_choice == computer_choice:
print("It's a tie.")
print("You win!")
else:
print("You lose.")
print('''
''')
elif ch=='4':
print('''
In this game, you'll have to guess the hidden word letter by letter, but be
careful – with each incorrect guess, a part of the hangman's gallows will be
constructed, and you'll need to solve the word before the hangman meets his fate!
''')
print('''
''')
Page 17 of 41
import tkinter as tk
import random
word = random.choice(words)
root = tk.Tk()
root.title("Hangman Game")
canvas.pack()
label.pack()
entry = tk.Entry(root)
entry.pack()
Page 18 of 41
# Create a button to check the user input
button.pack()
def check():
letter = entry.get().lower()
entry.delete(0, tk.END)
# Check if the letter is valid and has not been guessed before
guesses.append(letter)
if letter in word:
new_text = ""
for c in word:
if c in guesses:
else:
label.config(text=new_text)
Page 19 of 41
if new_text.replace(" ", "") == word:
label.config(text="You win!")
button.config(state=tk.DISABLED)
else:
mistakes += 1
draw_hangman(mistakes)
if mistakes == 6:
button.config(state=tk.DISABLED)
def draw_hangman(mistakes):
global canvas
if mistakes == 1:
elif mistakes == 2:
elif mistakes == 3:
elif mistakes == 4:
elif mistakes == 5:
Page 20 of 41
canvas.create_line(200, 200, 170, 230)
elif mistakes == 6:
button.config(command=check)
root.mainloop()
print('''
''')
elif ch=='5':
print('''
earn points and test your math skills. Let's get started
''')
import random
def generate_question():
Page 21 of 41
operator = random.choice(['+', '-', '*'])
answer = None
if operator == '+':
print(question)
try:
user_answer = int(user_answer)
if user_answer == correct_answer:
print("Correct!\n")
return True
else:
return False
except ValueError:
return False
def math_quiz():
Page 22 of 41
score = 0
num_questions = 10
for _ in range(num_questions):
if is_correct:
score += 1
if __name__ == "__main__":
math_quiz()
print('''
''')
elif ch=='6':
print('''
all know and love. This die will generate a random number
''')
import random
window = Tk()
window.minsize(600,600)
Page 23 of 41
window.title("ROLL THE DICE ")
label = Label(window,font=('bold',300))
#Label is not kept in function if it were, the label woukd keep changing
def roll():
number=['\u2680','\u2681','\u2682','\u2683','\u2684','\u2685']
# '\u2680' is a special code for showing the face of the dice containing a single dot
label.config(text=f'{random.choice(number)}')
label.pack()
heading.pack(fill=X) #to fill the heading bar instead of it just being it like a box
button=Button(window,text='Click me to roll!!',font=('normal',30),command=lambda:roll())
button.pack()
window.mainloop()
print('''
''')
elif ch=='0':
break
else:
print('''
''')
break
Page 24 of 41
OUTPUT
Page 25 of 41
If you choose 1 :
Page 26 of 41
If you choose 2 :
Page 27 of 41
If you choose 3 :
Page 28 of 41
If you choose 4:
Page 29 of 41
Page 30 of 41
Page 31 of 41
Page 32 of 41
Page 33 of 41
Page 34 of 41
Page 35 of 41
If you give correct word and win :
If you choose 5 :
Page 36 of 41
If you choose 6 :
Page 37 of 41
Page 38 of 41
If you choose invalid choice :
Page 39 of 41
REFERENCE
Page 40 of 41
THANK
YOU!
Page 41 of 41