Decode School

Multi Stage Guessing Game with Scoring Board

"Multi Stage Guessing Game and Points of every stage"
Create a three stage guessing game with point scoring in each stage the user must guess the secret number in five attempts. Range of Secret number should be increased at stage like 1 to 10 in stage in 1, 1 to 20 in stage 2 and 1 to 30 in stage 3. If the user correctly guessed the secret number, the system should display "your guess is correct" and moves to next stage; otherwise, it should tell the user whether the guessed number is higher or lower than the secret number and proceed to the next attempt. If the user fails to guess correctly after five attempts, the game should end with the message "Game Over, You Lose the Game." If user successfully guessed in all the three stages, display "You won the Game with scored points", then points scored at each level and stops the game.

At each stage the points will be awarded to user based on following condition

Solved in points
first attempt100
second attempt75
third attempt50
fourth attempt25
fifth attempt10

Hint : Sequence Type (list) is needed for this.
Objective : To learn the declaration and usage of list.

Program or Solution

					    
							
#hashed lines are comment lines used to illustrate the program
#import the built in method randint to generate an automatic secret number
from random import randint
# initiate level or stage as 1
level = 1
#sequence type to store points
points = [100,75,50,25,10]
#sequence type to store points scored at each level
points_scored = list()
#loop for 3 stages
while level <= 3:
#complexity range for each stage
end_value = level * 10
#secret number generation
secret_number = randint(1,end_value)
#looping statement for 5 attempts at each stage
for counter in range(0,5):
#gets the guessing number as user input
guess_number = int(input("Guess the secret number between 1 and {} ({} attempts left):".format(end_value,5-counter)))
#check guessing number is correct or higher or lower
if secret_number == guess_number:
print("Your Guess is Correct, You Won the level {} with {} points".format(level,points[counter]))
#add the point scored in this stage into the list
points_scored.append(points[counter])
level = level + 1
break
elif guess_number < secret_number:
print("Your Guess is lower than secret number")
else:
print("Your Guess is higher than secret number")
else:
print("Game Over, You Loose the Game, secret number is {}".format(secret_number))
break
else:
print("Congratz, You Won the Game with {} !!!".format(sum(points_scored)))
#loop to display scored points in every stage
for i in range(0,3):
print("level {} points {}".format(i+1, points_scored[i])) '''

Program Explanation

Logic is same as level 4, in addition,

points are stored using list

points_scored variable is a list which stores the points scored by user at each stage

the final for loop shows the points scored by user at each stage.