# Python Number Guessing Game mini Project

Contents

## 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.

### Syntax:

import random
random.randint(range of number)

`import randomgen_ran_no = random.randint(0,100)user_no = int(input('Enter Guessing number: '))if user_no == gen_ran_no:    print("YOU WIN THE GAME")else:    if user_no > gen_ran_no:        print('your number is greater')    else:         if user_no < gen_ran_no:             print('you number is smaller')print('Your Real number was:',gen_ran_no)`

#### Output:

`C:\Users\Pramod\PycharmProjects\pythonProject\venv\Scripts\python.exe C:/Users/Pramod/PycharmProjects/pythonProject/main.pyEnter Guessing number: 22you number is smallerYour Real number was: 50Process 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)
print(gen_ran_no)

### 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: 