Number Guessing Game: Python Exercise 3 Solution | Python Tutorial #29

preview_player
Показать описание
In this video, I have given you an exercise along with several related techniques to write effective python programs.
Рекомендации по теме
Комментарии
Автор

Ask the user a question. Read his answer and check if his answer is right or not. If right, say the answer is right. If wrong, prompt him to guess again. He can guess a maximum of 5 times. Before the last guess, give him a “last guess” warning. If he cannot guess within 5 times, display that he/she lost. If he guesses right within his chances, display: that his answer is right.

bhanushahi
Автор

Best programmer for me
learnt html, css and now learning python

BhaveshPatil-qomp
Автор

same question! Try to figure out, what should be the optimal
strategy to guess the number, mathematically.

AmitAbhishek
Автор

I am working on a script which allows you to track Amazon Product prices using Bs4 Can u make a Tutorial on Bs4?

RohanDasRD
Автор

Thanks, sir
I am very appreciative of this video.
May Allah give you long life and may you continue to teach people in the same way

clothingstorenearme
Автор

A Software Company has hired you for creating the guess letters program. The program has to estimate which characters exists in between two entered letters. For example: user entered two letters ‘a’ and‘d’ so your program must print ‘b’ and ‘c’ exists between the entered letters ‘a’ and ‘d’. *Use your father name starting and ending letters?

naeemrasheed
Автор

actualNumber = 45
attempts = 1
guessNumber = int(input("I am thinking of a number between 1 and 50. What is the number i AM THINKING OF?\n"))

while guessNumber != actualNumber:
attempts +=1

if guessNumber<actualNumber:
print(f"Your number, {guessNumber} is too low")
guessNumber = int(input("Try again!\n"))
elif guessNumber>actualNumber:
print(f"Your number, {guessNumber} is too high")
guessNumber = int(input("Try again!\n"))
else:
print(f"Congratulations!, {guessNumber} is the number and you guess it from {attempts} attempts")

Costel_Sava
Автор

import random

print("Enter the initial and final range between which your random number would be picked:")
u, v = int(input("Enter initial range: ")), int(input("Enter final range: "))

rand_num = random.randint(u, v) # assigns a random value between u and v to rand_num

user_num = attempts = 0
while rand_num != user_num:
user_num = int(input("Enter your guess!\n"))
if user_num == rand_num:
print("You guessed the number!")
elif user_num < rand_num:
if user_num < rand_num - 10:
print("Your guess is too low than the actual number!")
else:
print("Your guess is low than than the actual number.")
else:
if user_num > rand_num + 10:
print("Your guess is too large than the actual number!")
else:
print("Your guess is greater than the actual number.")
attempts+=1
print(f"You took {attempts} attempt(s) to guess the number!")

vikrantsinghbhadouriya
Автор

#guess the number

guess=50
def guessthenumber(i) :
a=int(input("Enter the number: "))
if(a==guess):
print(f"Your guess is correct and you have taken {i} attempts for the right answer")
elif(a<guess):
print("The value is too low\n")
i=i+1
guessthenumber(i)
else:
print("The value is too high\n")
i=i+1
guessthenumber(i)


i=1
guessthenumber(i)

PavanKumar-efws
Автор

Harry Sir mene solve kiya tha sabse pahle 😏😏😏 but aapne dekha nahi 😔 regular student of
Both channel (code&programming withHerry)

skynetwork
Автор

How can restart game like
Do want to play again yes/No
If no exit or if yes go back to while loop?

akashh
Автор

harry bhai code game end attempt kaise daily bo bta do means your attempt is over

GauravSharma-xlnc
Автор

sir i want to modify this code in such a way that when we start to play the game it provides the user a hint regarding the number so that it can be easy for him/her to play .So what coding we can do regarding this .
sir i am a student of class 11 and i have got a task to make a project using python and python is new to me so sir can you help me out with it
thank you

anandpandey
Автор

Plz make a project on online job portal using python

divyanigam
Автор

Hii Harry sir Im Gagan Bhatt
From uttarakhand 💕 new subscriber
& Old viewers from old id

gaganbhatt
Автор

I m Rahul n m from Haryana
Love you Harry bhai😘😘
Plzz say me hiiii once
Love u again 😘😘😘

PROTECHRAHUL
Автор

i was writing
"while our_num < player_num:"
it was
"while true"
only this minstake i was doing

N_S_Pablo