preloader

Making A Number Guessing Game In Python

Today we will make a number guessing game in python. A number guessing game is a user enters a number and it should match the number which the program has created.

Our number guessing game will little different the user will enter a number than if the number is wrong than the user will get a hint like your number is greater or lesser than the answer and the user will have 3 chances to answer the right answer.

It is a simple and easy project you should try to create this project on your own if you can’t than you can follow this article I will give the source code for this project.

If you are intrested in more projects like this than you can check out my projects that I have created at coderzway projects.

Let’s make a number guessing game in python

Contents

I hope you have knowledge of python basics and you have python installed on your machine if you don’t have python installed you can go to the python website and download – download python and remember to check add python to path while installing.

1. Create python file

Now first you need to create python file with .py extension you can go to any folder and create a python file and you need to open this file in a text editor I use vs code you can use any editor you can download vs code from here – download vs code.

2. Copy and paste

Now you have created the file now you can paste this code for number guessing game

How does this works

So I have used the random python module and it generates a random number between 1 to 15 you can increase this than asks for your input than it goes into the while loop checking if the answer is right or you have finished your chances if not it continues to ask the answer.

After this you can run this file by opening command prompt or terminal at the file location and type this in the command prompt python filename.py

This will run the file and this is the output

Output

How to use

1 – Enter a number and it will check if the number is correct
2 – If it is wrong you will get a hint and you have 3 chances

So this was number guessing game in python I know it was simple and easy but you can expand this project. If you want more projects do subscribe to coderzway newsletter and thank you for reading see you next time.

Spread the love

Related Post

0 Comment

  • M106.COM August 26, 2021

    I was very pleased to find this site. This is an intelligent and well written article, you must have put a fair amount of research into writing this. Thank you

  • Webmaster INFO September 5, 2021

    Thank you for the post on your blog. Do you provide an RSS feed?

  • We Love Google P:) September 6, 2021

    I beloved as much as you’ll obtain carried out right here. The sketch is tasteful, your authored subject matter stylish. nonetheless, you command get bought an nervousness over that you would like be delivering the following. sick unquestionably come further before again as exactly the same just about a lot ceaselessly within case you defend this increase.

Leave a Reply

Your email address will not be published. Required fields are marked *