You are on page 1of 27

YAYASAN SARAWAK INTERNATIONAL SECONDARY

SCHOOL PETRAJAYA

Python Report

Name: Constance Ting Sien Ni

Class: Y8-5

Subject: Computer Science

Teacher: Miss Christine

Date Submitted: 8th December 2023


1.0 Plan

When the game starts, the player will need to log in using their name, and input their age.
They must be between 7 and 10 years old so that it is available to play the game. If not,
they are not allow to play the game. They will then choose either pick the character they
want or create their own avatar to play as. If the player choose character, they have to
decide if they want to pick the prepared-character or create their own nickname. The
game have five levels and the difficulty will become harder according to its level. It will
need to ask the player five multiplication questions that are phrased sentences. For
example, instead of 2 x 5 it would ask questions such as ‘In the cave yousee 2 chests
each containing 5 coins. How many coins do you have?’ The player will get two attempts
to answer each question. If they get it right first time, they will receive 2 points. If they
get it right second time, they will receive 1 point. Otherwise, they will receive 0 points.
After the five questions have been asked, users will be given a score to indicate how well
they have done, including how many correct answers they got and how many they got
right at the first attempt.
2.0 Design
2.1 Flowchart
2.2 Program Code

import time
import random
time.sleep (0.5)
print("=============================================")
time.sleep (0.5)
print(" T H E T A B L E T O P C H R O N I C L E S ")
time.sleep (0.5)
print("=============================================")
time.sleep (0.5)
print("Welcome to The Tabletop Chronicles! I am Captain Tableau.")
print("\n")

class Player:
def __init__(self, name, age, character):
self.name = name
self.age = age
self.character = character

class Avatar:
def __init__(self, hair_style, hair_color, shirt_style, shirt_color, pants_style,
pants_color):
self.hair_style = hair_style
self.hair_color = hair_color
self.shirt_style = shirt_style
self.shirt_color = shirt_color
self.pants_style = pants_style
self.pants_color = pants_color

class Questions:
def __init__(self, levelone, leveltwo, levelthree, levelfour, levelfive):
self.levelone = questions_level1
self.leveltwo = questions_level2
self.levelthree = questions_level3
self.levelfour = questions_level4
self.levelfive = questions_level5

# list of possible multiplication questions for level 1


questions_level1 = {
" In the jungle, you see a pack of 2 monkeys, each carrying 3 bananas. How many
bananas are there in total? ":"6",
" You find a box with 5 rows of 2 cookies each. How many cookies are in the box?
":"10",
" As you walk through the city, you see 4 buildings, each with 3 floors. How many
floors are there in total? ":"12",
" You arrive at an amusement park with 3 rollercoasters, each with 1 car. How many
cars are there in total? ":"3",
" You see a group of 5 gazelles, each with 4 spots. How many spots are there in
total? ":"20",
}

# list of possible multiplication questions for level 2


questions_level2 = {
" You enter a factory with 4 assembly lines, each with 7 machines. How many
machines are there in total? ":"28",
" In the desert, you come across a caravan with 8 camels, each carrying 4 water
barrels. How many water barrels are there in total? ":"32",
" You find a group of 8 birds with 7 nests each. How many nests are there in total?
":"56",
" You arrive at a zoo with 8 animal enclosures, each with 9 animals. How many
animals are there in total? ":"72",
" You see a group of 10 foxes with 10 tails each. How many tails are there in total?
":"100",
}

# list of possible multiplication questions for level 3


questions_level3 = {
" You come across a group of 5 bee hives, each with 8 honeycombs. How many
honeycombs are there in total?":"40",
" You find a field with 11 rows of 2 pumpkins each. How many pumpkins are there in
total? ":"22",
" You enter a store with 10 aisles, each with 5 shelves. How many shelves are there
in total? ":"50",
" In the mountains, you see a group of 11 climbers, each carrying 11 ropes. How
many ropes are there in total? ":"121",
" You stumble upon a room with 12 chests, each containing 11 rubies. How many
rubies are there in total? ":"132",
}

# list of possible multiplication questions for level 4


questions_level4 = {
" You arrive at a racing event with 12 cars, each with 4 tires. How many tires are
there in total? ":"48",
" You come across a group of 9 wizards, each with 10 potions.Suddenly, 6 potions
broke. How many potions left?":"84",
" You find a gym with 11 exercise machines, each with 5 weights. A man then add 5
more weights to 1 exercise machine. How many weights are there in total? ":"60",
" You enter a temple with 12 chambers, each with 12 artifacts. How many artifacts
are there in total? ":"144",
" You stumble upon a kitchen with 12 chefs, each cooking 12 dishes. Then, a chef
come in. He then cook 23 dishes. How many dishes are there in total? ":"167",
}

# list of possible multiplication questions for level 5


questions_level5 = {
" In a forest, you see a group of 11 squirrels on a shady tree, each with 7 acorns.
Suddenly, 2 squirrels' acorn fell down of the tree. Each of them fall 3 acorns. How many
acorns are there in total? ":"71",
" You discover a cave with 5 chambers, each with 20 crystals. You take 63 crystals.
How many crystals left in the cave? ":"37",
" You enter a laboratory with 3 experiments, each with 27 test tubes. Suddenly, a
student broke 5 test tubes. How many test tubes left in the laboratory? ":"76",
" You stumble upon a group of 6 dragons, each with 135 hoards of gold. While you
are defeating them, 4 of them lost their gold. Each of them lost 29 hoards of gold. How
much gold left? ":"694",
" You find a garden with 4 rows of 23 trees each. On a stormy rainy day, 40 trees
strike by the lightning then fell down. How many trees left? ":"52",
}

time.sleep (0.5)
print("\n")
# ask for player's name and age
name = input("What is your name? ")
print("\n")
age = int(input("Hi " + name + "! How old are you? "))

time.sleep (0.5)
# check if player's age is within range
if age < 7 or age > 10:
print("Sorry, you are not within the age range to play this game.")
else:
print("Access granted!")
time.sleep (0.5)
# ask for player's character or avatar
character_choice = input("Do you want to play as a character or create your own
avatar? (character / avatar) ")
print("\n")
if character_choice.lower() == "character":
time.sleep (0.5)
print("\n")
character = input("Do you want to choose a character from the game or create your
own nickname? (character / nickname) ")
if character.lower() == "nickname":
time.sleep (0.5)
print("=================================")
time.sleep (0.5)
character = input("Please enter your own nickname: ")
print("Welcome " + character + "!")
print("\n")
time.sleep(0.5)
elif character.lower() == "character":
print("\n")
print("================")
time.sleep (0.5)
print("A: Mario")
time.sleep (0.5)
print("B: Aurora")
time.sleep (0.5)
print("C: Magnus")
time.sleep (0.5)
print("D: Patrick")
time.sleep (0.5)
print("E: Rainee")
time.sleep (0.5)
print("================")
# Dictionary to map numbers to character names
character_names = {
"A: Mario"
"B: Aurora"
"C: Magnus"
"D: Patrick"
"E: Rainee"
}
time.sleep (0.5)
character = input("Please enter your choice: ")
if character == "A":
print("Excellent choice! Welcome Mario!")
if character == "B":
print("Excellent choice! Welcome Aurora!")
if character == "C":
print("Excellent choice! Welcome Magnus!")
if character == "D":
print("Excellent choice! Welcome Patrick!")
if character == "E":
print("Excellent choice! Welcome Rainee!")
print("\n")
elif character_choice.lower() == "avatar":
print("\n")
print("=======================================================")
time.sleep (0.5)
gender = input("Please choose a gender for your character (girl/boy): ")
time.sleep (0.5)
print("Sure!")
time.sleep (0.5)
print("\n")
hair_style = input("What type of hairstyles do you want your avatar's hair to be?
")
time.sleep (0.5)
print("Sure!")
time.sleep (0.5)
print("\n")
hair_color = input("What color do you want your avatar's hair to be? ")
time.sleep (0.5)
print("Sure!")
time.sleep (0.5)
print("\n")
shirt_style = input("What type of shirts do you want your avatar's shirt to be? ")
time.sleep (0.5)
print("Sure!")
time.sleep (0.5)
print("\n")
shirt_color = input("What color do you want your avatar's shirt to be? ")
print("Sure!")
time.sleep (0.5)
print("\n")
if gender == "girl":
time.sleep (0.5)
print("\n")
bottom_choice = input("Which bottom do you prefer for your avatar?
(skirt/pant) ")
if bottom_choice == "skirt":
time.sleep (0.5)
print("Sure!")
time.sleep (0.5)
print("\n")
skirt_style = input("What type of skirt do you want your avatar's skirt to be?
")
time.sleep (0.5)
print("Sure!")
print("\n")
skirt_color = input("What color do you want your avatar's skirt to be? ")
time.sleep (0.5)
print("Sure! \n")
if bottom_choice == "pant":
time.sleep (0.5)
print("Sure!")
time.sleep (0.5)
print("\n")
pant_style = input("What type of pant do you want your avatar's pant to be?
")
time.sleep (0.5)
print("Sure! ")
pant_color = input("What color do you want your avatar's pant to be? ")
time.sleep (0.5)
print("Sure! ")
time.sleep (0.5)
else:
time.sleep (0.5)
pants_style = input("What type of pants do you want your avatar's pant to be?
")
time.sleep (0.5)
print("Sure! ")
time.sleep (0.5)
pants_color = input("What color do you want your avatar's pant to be? ")
print("Sure! ")
time.sleep (0.5)
shoes_style = input("What type of shoes do you want your avatar's shoes to be?
")
print("Sure! ")
time.sleep (0.5)
shoes_color = input("What color do you want your avatar's shoes to be? ")
print("Sure! ")
time.sleep (0.5)
avatar = Avatar(hair_style, hair_color, shirt_style, shirt_color, pant_style,
pant_color)
character_choice = input("Do you want to add some jewelry as ornaments?
(yes / no)")
if character_choice.lower() == "yes":
print("\n")
time.sleep (0.5)
print("A: bracelet")
time.sleep (0.5)
print("B: earings")
time.sleep (0.5)
print("C: necklace")
time.sleep (0.5)
print("D: hat")
time.sleep (0.5)
choice = input("Please enter your choice: ")
if choice == "A":
bracelet_choice = input("Which type of bracelet do you want? ")
time.sleep (0.5)
if choice == "B":
bracelet_choice = input("Which type of earings do you want? ")
time.sleep (0.5)
if choice == "C":
bracelet_choice = input("Which type of necklace do you want? ")
time.sleep (0.5)
if choice == "D":
bracelet_choice = input("Which type of hat do you want? ")
time.sleep (0.5)
elif character_choice.lower() == "no":
print("No problem.")
time.sleep (0.5)
character_choice = input("Do you want to add some more? (yes / no) ")
if character_choice.lower() == "yes":
print("\n")
print("A: bracelet")
time.sleep (0.5)
print("B: earings")
time.sleep (0.5)
print("C: necklace")
time.sleep (0.5)
print("D: hat")
time.sleep (0.5)
choice = input("Please enter your choice: ")
if choice == "A":
bracelet_choice = input("Which type of bracelet do you want? ")
time.sleep (0.5)
if choice == "B":
bracelet_choice = input("Which type of earings do you want? ")
time.sleep (0.5)
if choice == "C":
bracelet_choice = input("Which type of necklace do you want? ")
time.sleep (0.5)
if choice == "D":
bracelet_choice = input("Which type of hat do you want? ")
time.sleep (0.5)
elif character_choice.lower() == "no":
print("No problem.")
time.sleep (0.5)

print("======================================================= \n")
time.sleep (0.5)
character_choice = input("Do you want to add some more? (yes / no) ")
if character_choice.lower() == "yes":
print("\n")
print("A: bracelet")
time.sleep (0.5)
print("B: earings")
time.sleep (0.5)
print("C: necklace")
time.sleep (0.5)
print("D: hat")
time.sleep (0.5)
choice = input("Please enter your choice: ")
if choice == "A":
bracelet_choice = input("Which type of bracelet do you want? ")
time.sleep (0.5)
if choice == "B":
bracelet_choice = input("Which type of earings do you want? ")
time.sleep (0.5)
if choice == "C":
bracelet_choice = input("Which type of necklace do you want? ")
time.sleep (0.5)
if choice == "D":
bracelet_choice = input("Which type of hat do you want? ")
time.sleep (0.5)
elif character_choice.lower() == "no":
print("No problem.")
time.sleep (0.5)

print("======================================================= \n")
time.sleep (0.5)
character_choice = input("Do you want to add some more? (yes / no)
")
if character_choice.lower() == "yes":
print("\n")
print("A: bracelet")
time.sleep (0.5)
print("B: earings")
time.sleep (0.5)
print("C: necklace")
time.sleep (0.5)
print("D: hat")
time.sleep (0.5)
choice = input("Please enter your choice: ")
if choice == "A":
bracelet_choice = input("Which type of bracelet do you want? ")
time.sleep (0.5)
if choice == "B":
bracelet_choice = input("Which type of earings do you want? ")
time.sleep (0.5)
if choice == "C":
bracelet_choice = input("Which type of necklace do you want? ")
time.sleep (0.5)
if choice == "D":
bracelet_choice = input("Which type of hat do you want? ")
time.sleep (0.5)
elif character_choice.lower() == "no":
print("No problem.")
time.sleep (0.5)

print("======================================================= \n")
time.sleep (0.5)

time.sleep (0.5)
# explain to the players about how the game works
print("Awesome!! You're almost ready to start your adventure. I can't wait to see that!
But first, let me, the Captain Tableau explain how the game works. \n")
time.sleep(0.5)
print("------------^...^------------")
print(">>> You will be asked five multiplication questions that are phrased as
sentences. You will have two attempts to answer each question. If you get it right the
first time, you will receive 2 points. If you get it right the second time, you will receive 1
point. If you don't get it right after two attempts, you will receive 0 points. After the five
questions have been asked, you will be given a score to indicate how well you have
done. There are 5 levels. The questions will become harder and harder according to its
level. ")
print("------------^...^------------ \n")

time.sleep(0.5)
# ask the player if they want a tutorial or not
introduction_choice = input("Hmmm....it seem complicated (ー_ーゞ. Would you want to have
a tutorial? (yes/no) ")

if introduction_choice.lower() == "no":
print("Let's start the game!! Here we go! \n")

if introduction_choice.lower() == "yes":
time.sleep (0.5)
print("Sure! Mr. Tutorial, SHOW TIME!! [clap hand] ")
print("\n")
time.sleep (0.5)
print("______________________ T U T O R I A L __________________________")
time.sleep (0.5)
print(" .:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:.")
print("\n")
# list of possible multiplication questions for level 4
questions_tutorial= {
" If each hero collected 6 magic crystals and there are 4 heroes in total, how many
magic crystals did they collect altogether?" : "24",
" In the Enigma Forest, the heroes solve 5 different puzzles, and each puzzle has
7 levels. How many levels do they conquer in total?" : "35",
" During their journey, the heroes encounter 3 groups of mischievous Subtractors,
with each group consisting of 12 members. How many Subtractors do the heroes face
in total?" : "36"
}

score = 0

for questions_tutorial, answer in questions_tutorial.items():


time.sleep (0.5)
print(questions_tutorial)
attempts = 2
while attempts > 0:
time.sleep (0.5)
user_answer = input("What is your answer? ")
if user_answer.lower() == answer.lower():
if attempts == 2:
score += 2
else:
score += 1
print("Correct! \n ")
time.sleep (0.5)
break
else:
attempts -= 1
if attempts > 0:
print("Sorry, that is incorrect. Please try again: ")
else:
print("Incorrect. The correct answer is:", answer, "\n")

#Start the game


print("Now, you have finished your tutorial. Let's begin the game! Good luck to you! \
n")

time.sleep (0.5)

# initialize score counter


score = 0

print("___________________________+-×++-×++-×++-×++-×++-×++-
×+_________________________________")
time.sleep (0.5)
print("## Level 1")
print("\n")
for questions_level1, answer in questions_level1.items():
time.sleep (0.5)
print(questions_level1)
attempts = 2
while attempts > 0:
time.sleep (0.5)
user_answer = input("What is your answer? ")
if user_answer.lower() == answer.lower():
if attempts == 2:
score += 2
else:
score += 1
print("Correct! \n ")
time.sleep (0.5)
break
else:
attempts -= 1
if attempts > 0:
print("Sorry, that is incorrect. Please try again: ")
else:
print("Incorrect. The correct answer is:", answer, "\n")
# display final score for level 2
print("Congratulations!")
score_level1 = input("You got " + str(score) + " out of a possible 10 points, with " +
str(score//2) + " correct answers and " + str(score%2) + " correct on the second attempt.
\n")
time.sleep(0.5)

#Start level 2
print("## Level 2")
time.sleep (0.5)
print("Excellent! You have advanced to the next round successfully! \n")
time.sleep (0.5)

for questions_level2, answer in questions_level2.items():


time.sleep (0.5)
print(questions_level2)
attempts = 2
while attempts > 0:
time.sleep (0.5)
user_answer = input("What is your answer? ")
if user_answer.lower() == answer.lower():
if attempts == 2:
score += 2
else:
score += 1
print("Correct! \n ")
time.sleep (0.5)
break
else:
attempts -= 1
if attempts > 0:
print("Sorry, that is incorrect. Please try again: ")
else:
print("Incorrect. The correct answer is:", answer, "\n")

# display final score for level 2


print("Congratulations!")
score_level2 = input("You got " + str(score) + " out of a possible 20 points, with " +
str(score//2) + " correct answers and " + str(score%2) + " correct on the second
attempt.")
time.sleep(0.5)

# ask five questions for level 3


print("## Level 3")
time.sleep (0.5)
print("Superb! You have promoted to the next round successfully!")
time.sleep (0.5)
print("\n")

for questions_level3, answer in questions_level3.items():


time.sleep (0.5)
print(questions_level3)
attempts = 2
while attempts > 0:
time.sleep (0.5)
user_answer = input("What is your answer? ")
if user_answer.lower() == answer.lower():
if attempts == 2:
score += 2
else:
score += 1
print("Correct! \n ")
time.sleep (0.5)
break
else:
attempts -= 1
if attempts > 0:
print("Sorry, that is incorrect. Please try again: ")
else:
print("Incorrect. The correct answer is:", answer, "\n")

# display final score for level 3


print("Congratulations!")
score_level3 = input("You got " + str(score) + " out of a possible 30 points, with " +
str(score//2) + " correct answers and " + str(score%2) + " correct on the second
attempt.")
time.sleep (0.5)

#Start level 4
print("Excellent! You have finished your level 3. Let's begin level 4! \n")
time.sleep (0.5)

# ask five questions for level 4


print("## Level 4")
time.sleep (0.5)
print("Well done! You have successfully qualified to the next round! \n")
time.sleep (0.5)

for questions_level4, answer in questions_level4.items():


time.sleep (0.5)
print(questions_level4)
attempts = 2
while attempts > 0:
time.sleep (0.5)
user_answer = input("What is your answer? ")
if user_answer.lower() == answer.lower():
if attempts == 2:
score += 2
else:
score += 1
print("Correct! \n ")
time.sleep (0.5)
break
else:
attempts -= 1
if attempts > 0:
print("Sorry, that is incorrect. Please try again: ")
else:
print("Incorrect. The correct answer is:", answer, "\n")

# display final score for level 4


print("Congratulations!")
score_level4 = input("You got " + str(score) + " out of a possible 40 points, with " +
str(score//2) + " correct answers and " + str(score%2) + " correct on the second
attempt.")
time.sleep (0.5)

# ask five questions for level 5


print("## Level 5")
time.sleep (0.5)
print("Good job, my dear. You have advanced to the HARDEST round ———— level 5!
Go for it! \n")
time.sleep (0.5)

for questions_level5, answer in questions_level5.items():


time.sleep (0.5)
print(questions_level5)
attempts = 2
while attempts > 0:
time.sleep (0.5)
user_answer = input("What is your answer? ")
if user_answer.lower() == answer.lower():
if attempts == 2:
score += 2
else:
score += 1
print("Correct! \n ")
time.sleep (0.5)
break
else:
attempts -= 1
if attempts > 0:
print("Sorry, that is incorrect. Please try again: ")
else:
print("Incorrect. The correct answer is:", answer, "\n")

# display final score for level 5


print("Congratulations!")
score_level5 = input("You got " + str(score) + " out of a possible 50 points, with " +
str(score//2) + " correct answers and " + str(score%2) + " correct on the second
attempt.")
# Feedback based on the total score achieved
total_score = score_level1 + score_level2 + score_level3 + score_level4 + score_level5
if total_score == 0:
print("You didn't score any points. Don't worry, practice makes perfect!")
elif total_score <= 10:
print("You've made some progress. Keep practicing to improve your skills.")
elif total_score <= 20:
print("Well done! You have a decent score. Keep practicing to aim for an even higher
score next time.")
else:
print("Congratulations! You scored impressively high. Keep up the great work!")

# Additional feedback or encouragement can be added based on specific score ranges


3.0 Testing

Test number Data entered Expected outcome Pass / Fail

1. User who is too Username = Juliet “Sorry, you are not Pass
young is not allowed Age = 6 within the age range to
to play. play this game ” and the
program exits.

2. User who is too old Username = Romeo “Sorry, you are not Pass
is not allowed to play. Age = 11 within the age range to
play this game ” and the
program exits.

3. User who is between Username = Bobo “Access granted” and Pass


7-10 years old is Age = 10 continue the program.
allowed to play.

4. User choose a Please enter your “Sure!” and continue the Pass
gender for her avatar. choice = girl program.

5. User choose a “What type of hair “Sure!” and continue the Pass
hairstyle for her avatar. styles do you want your program.
avatar's hair to be?” =
bun

6. User choose a color “What color do you “Sure!” and continue the Pass
for her avatar’s hair.. want your avatar's hair program.
to be?” = black

7. User choose a “Which bottom do you “Sure!” and continue the Pass
bottom for her avatar. prefer for your avatar?” program.
= B

8. User choose a pant “What type of pant do “Sure!” and continue the Pass
for her avatar. you want your avatar's program.
pant to be?” = jeans

9. User choose a color “What color do you “Sure!” and continue the Pass
for her avatar’s pant. want your avatar's pant program.
to be?” = blue

10. User choose a “What type of necklace “Sure!” and continue the Pass
necklace for her do you want?” = chain program.
avatar.
4.0 Review and Evaluation

My partner, Jia En, her game is quite good. It covers all the requirements and is easy to
use. Her codes are long but the output is short, so it does not take too much time to
choose a character or anything. Her game focuses on the math multiplication timetables,
which is our main objective. The questions are easy to understand and suitable for 7-10-
year-old children. Lastly, her game does calculate the score correctly depending on the
number of the right answer.

According to the requirements, our game has to be suitable for 7-10-year-old children,
mine as well. However, the last two levels might be challenging for them as the standard
of the last two levels is higher than the other levels. To make them easier, I could change
the standard of those two levels to the normal standard, but the questions will be more
complicated than the others since the difficulty will become more harder and harder
according to the levels. The most challenging in this process is to crack the secret code.
Sometimes I even wanted to punch my laptop, but luckily I solved it. I searched on
Google or asked for help. For the length of the game, I think maybe it is too long because
some of it was used to decorate the game.
5.0 Conclusion

List of recommendations to improve my game:


1. Make it shorter, so it will not be complicated.
2. Make the questions understandable for 7-10 years old children.
3. Focus on the main objective.

In this process of making my own game, I have definitely learnt to play the code on
Python. I have gained a lot of knowledge on coding such as those special “words” on
Python. Besides that, I have also learnt to manage my time wisely, so that I will not felt
anxious about rush lots of projects in a month. I did a time table to prevent last minute
mistakes. I gained a lot of knowledge in this process. I hope that I can do better in the
future and make a real APP.

You might also like