Python Number Guessing Game mini Project

Number Guessing Game in Python with Source Code

Now we are going to create a simple number guessing game project in python. For this mini-project, we have to import a python package called random then we will use randint() module to generate a random integer number. Randint module will take the argument as a range of numbers. 


import random
random.randint(range of number)

Number Guessing Game Source Code Download

import random

gen_ran_no = random.randint(0,100)

user_no = int(input('Enter Guessing number: '))

if user_no == gen_ran_no:



if user_no > gen_ran_no:

print('your number is greater')


if user_no < gen_ran_no:

print('you number is smaller')

print('Your Real number was:',gen_ran_no)


C:\Users\Pramod\PycharmProjects\pythonProject\venv\Scripts\python.exe C:/Users/Pramod/PycharmProjects/pythonProject/
Enter Guessing number: 22
you number is smaller
Your Real number was: 50

Process finished with exit code 0

How do you Generate Random Numbers in Python?

First we have to import package called random then #use randint() module to generate randam integer number. Example is given below:
import random
gen_ran_no = random.randint(0,100)

How do you Play the Number Guessing Game?

Just simply enter any number randomly, if that number is equal to that number which is generated by the program then you will be the Winner otherwise it will show that your number smaller or greater, and last it will also show you what was the number generated by the program.

Recommended Post:

Get Salesforce Answers

Hi, I’m Pramod Kumar Yadav & a computer science Engineer with 3years of experience in Digital marketing. I’m self-motivated and love to do SEO.

Best PYthon Course

Get More trending Courses

Leave a Reply

%d bloggers like this: