Random Number Guessing Game Using Python

preview_player
Показать описание
Randon number guessing game using python 3.5.2. I use the module random and i explain code line by line to give you a good understanding of the code. I will be uploading more tutorial in the coming time. Thanks for watching, Please leave a like comment and suscribe.
Рекомендации по теме
Комментарии
Автор

Thank You, now I have something to show off in my class.

emilianog
Автор

Great tutorial, looking forward to seeing more of these! :)

AWTmedia
Автор

I’m terrible at python I’m struggling in my computer science class thank you so much

goosimusic
Автор

Great video, guess you will upload more videos related to python

hireath
Автор

Hey David Kaplan,
[Don't take it on heart.
but your program is something large.
I DO NOT WANT TO INSULT YOU AT ALL.
This can help you in your further videos.]
A better program is below:
import random
no_of_guesses = 1
highest = int(input("Please enter the highest value you want to guess the number between (starting from 1): "))
answer = random.randint(1, highest)
guess = 0
while guess != answer:
guess = int(input())
if guess < answer:
print("Please guess higher")
no_of_guesses += 1
elif guess > answer:
print("Please guess lower")
no_of_guesses += 1
else: #elif guess == answer:
print("You got that!")
print("You guessed the {} in {} times. Congratulations!".format(answer, no_of_guesses))


[AGAIN, Please don't take this on heart, even people who are viewing this comment.]

swaritjain
Автор

At the beginning, instead of:
print(Hello! What is your name?)
name = input()
Could you do:
name = input('Hello! What is your name?')

szczypien
Автор

Can you copy and paste in chat It would help a lot I have hw on this

Versinex
Автор

there is a error showing in my python code, it is the same code as copied from the tutorial, the error is in, line 18, in <module>, if guess < number:
TypeError: '<' not supported between instances of 'str' and 'int' you please help me out

nernaykumar
Автор

Feel like im back in secondary, its all coming back to me

aurelianaudio
Автор

print("guess a number between 1-100")
import random
num = random.randint(0, 100)


hisnum = int(input("your guess is: "))




while hisnum<num :
print("guess higher")
hisnum = int(input("your guess is : "))
while hisnum>num :
print("guess lower")
hisnum = int(input("your guess is : "))


if num==hisnum:
print("you got it")
input("press enter to exit: ")


#PLEASE, CAN SOMEONE TELL WHAT IS WRONG WITH THIS CODE, SOMETIMES IT RUNS GOOD
BUT SOMETIMES IT DIDN T WORK, HELP PLEASE

saturn
Автор

When I did it it said that I did it in 0 tries

dealbreaker_gamez
Автор

How do I do play again? It keeps bugging-

mysticmess
Автор

i followed the code,
import random
numofguesses = 0

print("What is ur name? im a creep so i needa know")
name = input()

number = random.randint (1, 20)
print("The number i have generated is between 1 and 20 ", +name)

while numofguesses < 6:
print("Guess Nerd. ")
guess = input()
guess = int(guess)

numofguesses = numofguesses + 1
if guess < number:
print("Lower")
if guess > number:
print("Higher")
if guess == number:
break
if guess == number:
numofguesses = str(numofguesses)
print("GG " +name, "You got the number in ", +numofguesses
if guess != number:
number = str(number)
print("L, the number was: " +number)

but when i get the the if guess != number, it says that the : after is an invalid syntax, please help
if guess != number:

MiniRavioli
Автор

How do you add points to the guessing game?

spencerkaneki
Автор

Following this from experience with me it LITERALLY kept spamming take a guess over and over for windows version

Thefrostedslime
Автор

I get a SyntaxError and a big line next to numofguesses = numofguesses + 1

and it says unident does not match any outer indetation level

fshmail
Автор

the font is too small. you should have used the zoom

janakiyeluripati
Автор

how would I change it to have an infinite amount of guesses?

claybarrows
Автор

But how do you get the game into a window?

prinssinakki
Автор

How do I ask for the number of guesses

austinwakanda
visit shbcf.ru