Guessing Game in Python

preview_player
Показать описание
Learn how to build a simple yet engaging program that challenges users to guess a number. Join us on this hands-on journey to enhance your Python skills and create interactive games with ease.

============================
Do you want to learn from me?
============================

📱 Grow with us:
Рекомендации по теме
Комментарии
Автор

Pehli baar programming ki feel aayi.

Kitna dhanyavaad doon sir aapka. Stay blessed .

jinks
Автор

Paused the video and tried doing it on my own.

import random
num= random.randint(1, 50) # this is the correct number

count = 0
while True:
guess = int(input("guess the correct number from 1 to 50:"))
if guess > num:
print("guess lower")
count+=1
elif guess < num:
print("guess higher")
count+=1
else:
print("bingo")
count+=1
print(f"You took {count} attempts to guess the correct number")
break




Then watched the video and realized your code is much better :')

RickC-ewzs
Автор

u r the most underrated teacher on is awesome man

unheardanonymousvoice
Автор

This is what I was searching, thankyou so much☺. Your explanation is so good 👍

harishverma
Автор

sir i have tried to solve this with the help of for loop if we give user a defined range of number let say 1-10, please reply if my code needs any further improvement.

import random

jackpot = random.randint(1, 11)

guess = int(input("guess kar ek number from 1-10 :- "))

for guess in range(1, 11):
if guess == jackpot:
print("tu sahi hai")
break
else:
print("tu galat hai")

guess = int(input("phir ek bar guess kar ek number from 1-10 :- "))

YashPatil-knnh
Автор

Guess higher infinite kyu chal raha any answer please

sheetalsharma
Автор

why am i getting below error?


jackpot = random.randint(1, 100)

guess = int(input("Chal guess kar"))

while guess != jackpot:
if guess < jackpot:
print("Guess higher")
else:
print("Guess lower")

guess = int(input("Chal Guess Kar"))

print("sahi Jawab")

NameError Traceback (most recent call last)
Cell In[6], line 1
----> 1 jackpot = random.randint(1, 100)
3 guess = int(input("Chal guess kar"))
5 while guess != jackpot:

NameError: name 'random' is not defined

chanakyapandey
Автор

error q araha hai,

random.randint(1, 100)

NameError Traceback (most recent call last)
Cell In[3], line 1
----> 1 random.randint(1, 100)

NameError: name 'random' is not defined

chanakyapandey