0% found this document useful (0 votes)
33 views

Python Game

The Python script creates a number guessing game that works as follows: 1. The user inputs the number of times they want to play and the lower and upper bounds of the random number range. 2. A random number is generated between the bounds and stored for comparison. 3. The user gets 3 chances to guess the number. Hints tell if guesses are too high or low. 4. If correct, the user gets a point and congratulations. Otherwise they are told to try again. 5. The total score out of total games is printed at the end.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

Python Game

The Python script creates a number guessing game that works as follows: 1. The user inputs the number of times they want to play and the lower and upper bounds of the random number range. 2. A random number is generated between the bounds and stored for comparison. 3. The user gets 3 chances to guess the number. Hints tell if guesses are too high or low. 4. If correct, the user gets a point and congratulations. Otherwise they are told to try again. 5. The total score out of total games is printed at the end.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

REPORT

On

Python script guessing game


Submitted by

Name Registration no

Pratik kumar 12214666

Hisham shoukath 12206014

Aditya bhardhwaj 12213266

Program Name: Bachelor of Technology


(Computer Science and Engineering)

Under the Guidance of

Akshara Rana

School of Computer Science & Engineering


Lovely Professional University
(October-November 2022)
DECLARATION

I hereby declare that I have completed my Python Mini project on guessing


game from a given sentence from 03-10-2022 to 24-11-2022 under the
guidance of Akshara Rana. I have declared that I have worked with full
dedication during these six weeks to fulfil the requirements of training for the
award of degree of Bachelor of Technology (Computer Science and
Engineering), Lovely Professional University, Phagwara

Date: 24-11-2022 Signature


Registration No: 12214666
Registration No: 12206014
Registration No: 12213266
ACKNOWLEDGEMENT

Primarily I would like to thank God for being able to learn a new technology.
Then I would like to express my special thanks of gratitude to the teacher who
provide me the golden opportunity to learn a new technology from home.

I would like to also thank my own college Lovely Professional University for
offering such a course which not only improve my programming skill but also
taught me other new technology.

Then, I would like to thank my parents and friends who have helped me with
their valuable suggestions and guidance for choosing this course.

I am making this project not only for marks but to also increase my knowledge.
THANKS AGAIN TO ALL
The task is to create a script that generates a random number between
a fixed range, and if the user guesses the number right in three
chances, then user wins otherwise user lose.
This game user can play as many numbers of times and whenever
user wins a score is to be given to the user.
At the end the users score must be displayed on the screen.
Hint: Make use of random module to design the game
Abstract steps:
• The user enters the lower and upper bounds of the range.
• As a result, the compiler generates a random integer between the
range and stores it in a variable for future use.
• A while loop will be created for repetitive guessing.
• When a user guesses a number that is greater than a randomly
selected number, the user receives the message “have one more try”.
Your guess was too high.
• If the user guesses a number smaller than a randomly selected
number, the user gets an output of “have one more try “. Your guess
was too small”
• In addition, if the user guesses within a minimum number of
attempts, they get a “Congrat’s” message and also get the winning
scores.
• If the user fails to guess the integer in the minimum number of
guesses, he/she will receive a “Better Luck Next Time!
(Student is free to decide the input and output layout for this mini
project)
Source Code:

import random
print('Guessing game')
co=int(input("How many times you want to play: "))
score=0
for i in range(co):
print(f'Chance number {i+1}')
a=int(input("Enter the lower boundary: "))
b=int(input("Enter the upper boundary: "))
c=random.randint(a,b)
guess=None
no_guess=0
limit=3

while no_guess<limit:
guess = int(input(f'Enter a number between {a} and {b}: '))
no_guess+=1
if guess==c:
print("Congo")
score+=1
break
else:
print("try again")
print(f'Your total score is {score} out of {co}')
Output:

You might also like