Comments on: Guessing Game Implementation in Python https://www.pythonforbeginners.com/code-snippets-source-code/python-guessing-game Learn By Example Tue, 17 Jan 2023 06:21:18 +0000 hourly 1 https://wordpress.org/?v=5.8.13 By: Loni Tande https://www.pythonforbeginners.com/code-snippets-source-code/python-guessing-game#comment-125486051 Tue, 17 Jan 2023 06:21:18 +0000 https://www.pythonforbeginners.com/?p=807#comment-125486051 What if you want to steadily guide the user to the number? Say you print “low” when the user’s guess is close to the randomly generated number and “high” otherwise.

Say the randomly generated number is 50. If the user guesses:

1. 5 -> print “too low”

2. 25 -> low

3. 35 -> almost there

4. 67 -> high

5. 89 -> too high

6. 45 -> almost there

7. 50 -> correct

How exactly would you implement this please?

]]>
By: Aditya https://www.pythonforbeginners.com/code-snippets-source-code/python-guessing-game#comment-125300961 Wed, 28 Dec 2022 18:52:25 +0000 https://www.pythonforbeginners.com/?p=807#comment-125300961 Fixed. Check Now.

]]>
By: Dev Makwana https://www.pythonforbeginners.com/code-snippets-source-code/python-guessing-game#comment-123071163 Tue, 14 Jun 2022 14:43:51 +0000 https://www.pythonforbeginners.com/?p=807#comment-123071163 Sir what can I extra add in this mini project pls tall me !

]]>
By: Ihsan Ayyach https://www.pythonforbeginners.com/code-snippets-source-code/python-guessing-game#comment-121189877 Fri, 14 Jan 2022 19:37:56 +0000 https://www.pythonforbeginners.com/?p=807#comment-121189877 while n != "guess":

see actually here the condition is always True regardless the guessed number
because we are comparing int to str

for example : while 4 != "4" This is True so python will excute the loop
also while 4 != "3" True

when we are comparing a number to str the answer always false because they are different type so they are no equal even if the string has the same number of the integer

finally,
He did this way only to make the whole code inside the while loop you can code the same game in different way also by saying while n> 0 it will be same _



]]>
By: mike https://www.pythonforbeginners.com/code-snippets-source-code/python-guessing-game#comment-115229041 Wed, 25 Aug 2021 06:47:25 +0000 https://www.pythonforbeginners.com/?p=807#comment-115229041 Thanks! this helped a lot

]]>
By: rahat https://www.pythonforbeginners.com/code-snippets-source-code/python-guessing-game#comment-114819588 Tue, 10 Aug 2021 04:04:15 +0000 https://www.pythonforbeginners.com/?p=807#comment-114819588 Yeah sure please correct me

]]>
By: rahat https://www.pythonforbeginners.com/code-snippets-source-code/python-guessing-game#comment-114819492 Tue, 10 Aug 2021 03:55:45 +0000 https://www.pythonforbeginners.com/?p=807#comment-114819492 Yeah for sure and check if I can execute I have some errors can’t execute

]]>
By: rahat https://www.pythonforbeginners.com/code-snippets-source-code/python-guessing-game#comment-114817964 Tue, 10 Aug 2021 01:06:59 +0000 https://www.pythonforbeginners.com/?p=807#comment-114817964 #Guest

##One player vs. the computer

import random

minGuess = 1

maxGuess = 6

##Ask the user for their name and their guess

name =input (“What is your name? “)

print(“Hi + name!”)

print(“Enter an number between: ” + missGuess + ” and ” + maxGuess)

guess = int(input (“What is your guess?”))

##Generate a random number and tell the user if they won or lost

secretNumber = random.randint(minGuess, maxGuess)

if (guess != ?????)

print(“Congratulations, you got it right!”)

else:

print(“You lose – the number was ???”)

print(“Thank you for playing Guess the Number.”)

Can you please help me to correct the program

]]>
By: rahat https://www.pythonforbeginners.com/code-snippets-source-code/python-guessing-game#comment-114817959 Tue, 10 Aug 2021 01:06:06 +0000 https://www.pythonforbeginners.com/?p=807#comment-114817959 #Guest

#One player vs. the computer

import random

minGuess = 1

maxGuess = 6

#Ask the user for their name and their guess

name =input (“What is your name? “)

print(“Hi + name!”)

print(“Enter an number between: ” + missGuess + ” and ” + maxGuess)

guess = int(input (“What is your guess?”))

#Generate a random number and tell the user if they won or lost

secretNumber = random.randint(minGuess, maxGuess)

if (guess != ?????)

print(“Congratulations, you got it right!”)

else:

print(“You lose – the number was ???”)

print(“Thank you for playing Guess the Number.”)

Can you please help me to correct the program

]]>
By: rahat https://www.pythonforbeginners.com/code-snippets-source-code/python-guessing-game#comment-114817948 Tue, 10 Aug 2021 01:04:03 +0000 https://www.pythonforbeginners.com/?p=807#comment-114817948 #Guest

#One player vs. the computer

import random

minGuess = 1

maxGuess = 6

#Ask the user for their name and their guess

name =input (“What is your name? “)

print(“Hi + name!”)

print(“Enter an number between: ” + missGuess + ” and ” + maxGuess)

guess = int(input (“What is your guess?”))

#Generate a random number and tell the user if they won or lost

secretNumber = random.randint(minGuess, maxGuess)

if (guess != ?????)

print(“Congratulations, you got it right!”)

else:

print(“You lose – the number was ???”)

print(“Thank you for playing Guess the Number.”)

]]>