0% found this document useful (0 votes)
4 views1 page

Number Guessing Game in Python

This document outlines a simple number guessing game where the user must guess a randomly selected number between 1 and 100. The game provides feedback on whether the user's guess should be higher or lower until the correct number is guessed. Once the user guesses correctly, the game congratulates them and displays the number of attempts taken.

Uploaded by

kamakshig2001
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Number Guessing Game in Python

This document outlines a simple number guessing game where the user must guess a randomly selected number between 1 and 100. The game provides feedback on whether the user's guess should be higher or lower until the correct number is guessed. Once the user guesses correctly, the game congratulates them and displays the number of attempts taken.

Uploaded by

kamakshig2001
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

import random

import time

print ("Hi, Welcome to the game, picking a value for you to guess between 1 to
100")
[Link](2)
print ("I picked it, did you?")
[Link](2)
guess = int(input("What's your number?: "))
correct_number = [Link](1,100)
guess_count = 1

while guess!= correct_number:


guess_count += 1

if guess < correct_number:


[Link](1)
guess = int(input("Hey, you can do better by thinking higher. What's your
number?: "))
else:
[Link](1)
guess = int(input("Hey, you can do better by thinking lower. What's your
number?: "))

[Link](2)
print(f"Congrats! The right guess is {correct_number}. You got it right in
{guess_count} guesses.")

You might also like