Very Easy "Guess The Number" Game in Python

This is a game where you have to guess the number picked by the computer in the 

range of 1 to 50


The Program Will Keep Running Until The User Guesses the Right Number


It is written in Python 3.8.0


Enjoy...

Source Code:

#importing random module for selecting random number between 1 - 50

import random

#computer saving a random number between 1-50 in the variable name "number"

number = random.randrange(1,50)

#User Starts Guessing The Number

guess = int(input("Guess A Number Beetween 1 - 50: "))

#now the program will keep running until the user guesses the right number

while guess != number:
    if number > guess:
        print("You Need To Guess A Higher Number, Try Again!")
        guess = int(input("Guess A Number Beetween 1 - 50: "))
    else:
        print("You Need To Guess A Lower Number, Try Again!")
        guess = int(input("Guess A Number Beetween 1 - 50: "))

print("\nCongrats You Guess It Correct!!")        

Thanks For Visiting


*PLEASE USE FOR EDUCATIONAL PURPOSE ONLY

Aditya Shrivastava | MyProgramArchives

Comments

Popular posts from this blog

Compare The Tripets | HackerRank Problem Solved by Aditya Shrivastava

Alphabets Module by Aditya Shrivastava | FULL DOCUMENTATION

Mensurator | A Python Program Which Will Calculate Perimeter Or Area For You