import random num = random.randint(1,50) diff_level=input("Enter the level of difficulty...Type 'easy' or 'hard': ") if diff_level == "easy": attempts = 10 print(f"Yor have {attempts} attempts to guess the number!")
elif diff_level == "hard": attempts = 5 print(f"Yor have {attempts} attempts to guess the number!")
else: print("Enter valid input!")
while (diff_level == "easy" and attempts > 0) or (diff_level == "hard" and attempts > 0): guess = int(input("Make a guess: ")) if attempts == 0: print("You lost") elif guessnum: print("Your guess is too high!") attempts-=1
else: print("Your guess is correct...You won!") break
This code is easy one... import random import logo_art def no_guesses(attempts,i): if attempts - i != 0: print('guess again') return (f"you have {attempts - i} attempts remaining to guesses the number") else: return ('you are out of guesses,you lose!!') def easy_hard(choose_num,attempts): print(f"you have {attempts} attempts remaining to guess the number!") for i in range(1,attempts + 1): guess = int(input('make a guess')) if guess > choose_num: print('your guess is too high') print(no_guesses(attempts,i)) elif guess < choose_num: print('your guess is too low') print(no_guesses(attempts,i)) else: print(f'you guess is right...The answer was {choose_num}') break print(logo_art.logo) print('let me think of a number between 1 to 50.') num_list = list(range(51)) choose_num = random.choice(num_list) while True: level = input("Choose level of difficulty...Type 'easy' or 'hard' : ") if level == 'easy': easy_hard(choose_num,attempts = 10) break elif level == 'hard': easy_hard(choose_num,attempts = 5) break else: print("you've entered wrong input,Try again")
import random level=input("type 'easy' or 'hard' to choose the level: ").lower() if level=="easy": print("you have 10 attempts to guess the number between 1 to 50") attempts=10 elif level=="hard": print("you have 5 attempts to guess the number between 1 to 50") attempts=5 else: print("invalid input") number=random.randint(1,50) print(number) print(level) while (level == "easy" and attempts > 0) or (level == "hard" and attempts > 0): guess=int(input("guess a number: ")) if guessnumber: print("too high") attempts-=1 print(f"you have {attempts} attempts left") else: print("u guessed it right") break
from random import randint from L import LOGO print(LOGO) print() print("Think of a number between 1 to 50. ") while True: choice = input("Choose difficulty level... type 'easy' or 'hard': ").lower() options = ['hard', 'easy'] if choice not in options: print("Enter valid option") else: break if choice == "hard": count = 5 print(f"you have {count} attempt remaining to guess the number.") else: count = 10 print(f"you have {count} attempt remaining to guess the number.") numbertoguess = randint(30, 40) counter = False guess = int(input("Make a guess: ")) while not counter: if guess < numbertoguess: print("Your guess is too low Guess again") count = count - 1 print(f"you have {count} attempt left")
elif guess > numbertoguess: print("Your guess is too high Guess again") count = count - 1 print(f"you have {count} attempt left") else: print("Your guess is right... You win") print(f"the number is {numbertoguess}") break if count == 0: counter = True print("You are out of guesses") break else: guess = int(input("Make a guess: "))
import random def guess_the_number_game(): print("Choose level of difficulty... Type 'easy' or 'hard':") level = input().lower() # Set number of attempts based on difficulty level attempts = 10 if level == 'easy' else 5 number = random.randint(1, 100) # Random number between 1 and 50 print(f"You have {attempts} attempts remaining to guess the number!") while attempts > 0: guess = int(input("Make a guess: ")) if guess < number: print("Your guess is too low.") elif guess > number: print("Your guess is too high.") else: print(f"Congratulations! You've guessed the number {number} correctly.") break attempts -= 1 if attempts > 0: print(f"Guess again! You have {attempts} attempts remaining.") else: print(f"Sorry, you're out of attempts. The correct number was {number}.") # Run the game guess_the_number_game()
import random print("guess the number") computer_guessed=random.randint(1,50) difficulty_level=input("enter a difficulty level 'hard' or 'easy':") if difficulty_level=="easy": print("you have 10 chances") for i in range(1,10): human_guessed_number=int(input("enter a no")) if computer_guessed==human_guessed_number: print("you are correct") break elif human_guessed_number>computer_guessed: print("your guess is more") elif human_guessed_number computer_guessed: print("your guess is more") elif human_guessed_number < computer_guessed: print("your guess is low") else: print(f"try again {4-i}")
Major steps involved in the code: Import the necessary modules: random and logo_art. Define constants for the number of attempts allowed for each difficulty level. Define a function set_difficulty that takes the chosen level (‘easy’ or ‘hard’) and returns the corresponding number of attempts. Define a function check_answer that compares the guessed number with the answer and provides feedback (too low, too high, or correct). Define the main game function game: Display a logo. Generate a random number between 1 and 50 as the answer. Ask the user to choose a difficulty level. Set the number of attempts based on the chosen level. Repeatedly prompt the user to guess a number: Display the remaining attempts. Check if the guessed number is correct or not. Update the remaining attempts. End the game if the user guesses correctly or runs out of attempts.
import random print("Think a number between 1 to 50.") number = random.randint(1, 50) # print(number) level = int(input("Choose level of difficulty...for 'easy' type (1) or for 'hard' type (2): ")) no_guess=0 def num(level): if level==1: global no_guess no_guess = 10 elif level==2: no_guess = 5 num(level) while no_guess>=1: print(f"You have {no_guess} attempts remaining to guess the no.") guess = int(input("Make a guess: ")) if guess>number: no_guess -= 1 print("Your Guess is Too high.") elif guess=1: print("Guess again!") if no_guess==0 and guess!=number: print("You Lose the Game...☹☹!!")
import random print("guess the numbers from 1 to 100:" ) answer = random.randint(1,100) choose_level = input("choose level of difficulty Type 'easy' or 'hard': ") if choose_level == 'easy': print("you have 10 attempts to guess the number:" ) attempts = 10 while attempts>0: guess_number = int(input(" enter the guess number:")) if guess_number == answer: print(f"your guess number {guess_number} is correct you won") break elif guess_number < answer: print("your guess is low:") attempts = attempts-1 if attempts == 0: print("you lost") else: print(f"guess again and you have {attempts} attempts only") elif guess_number > answer: print("your guess is high:") attempts = attempts-1 if attempts == 0: print("you lost") else: print(f"guess again and you have {attempts} attempts only") elif choose_level == 'hard': print("you have 5 attempts to guess the number:") attempts = 5 while attempts>0: guess_number = int(input(" enter the guess number:")) if guess_number == answer: print(f"your guess number {guess_number} is correct and won") break elif guess_number < answer: print("your guess is low:") attempts -= 1 if attempts == 0: print("you lost") else: print(f"guess again and you have {attempts} attempts only" ) elif guess_number > answer: print("your guess is high:") attempts -= 1 if attempts == 0: print("you lost") else: print(f"guess again and you have {attempts} attempts only" ) else: print(" you have entered wrong level name and select proper level")
"""Guess the no""" import random print("guess the no") randomno=random.randint(1,30) print(randomno) level=1 user_level=input("which level you want easy/hard") chances = 10 hard_chance=5 def diffrence(a,b): newone=range(a,b) if len(newone)>=1 and len(newone)11 and len(newone) 21 and len(newone)
import random answer = random.randint(1,50) level = input("Choose your level (Easy / Hard): ").lower() if level == 'easy': chances = 10 elif level == 'hard': chances = 5 while True: user = int(input("Enter a number between 1 and 50: ")) if user == answer: print(f"{user} is the correct guess. You won!") break elif user > answer: print("Your guess is too high") chances -= 1 if chances > 0: print(f"You have {chances} attempts left") else: print("You have no attempts left. You lose!") break else: print("Your guess is too low") chances -= 1 if chances > 0: print(f"You have {chances} attempts left") else: print("You have no attempts left. You lose!") break
# Assignment answer :- Ask level again, when we mistakenly typed wrong Difficulty level. print(num_logo.logo) print("Let me think of a number beetween 1 to 50.") answer= random.randint(1,50) def game(): level= input("Choose level of Difficulty--> Type 'easy' or 'hard'=").lower() attempts= set_difficulty(level) if attempts!= EASY_LEVEL_ATTEMPT and attempts!= HARD_LEVEL_ATTEMPT: print("You have entered wrong difficulty level, Play Again!") return game()
import random def guess_game(num,level): if level=='hard': count=5 else: count=10 flag=True i=0 while inum: print("Its too high") print("Guess Again") elif guess
import random attempts = 0 def easy_or_hard(): global attempts attempts -= 1 user = int(input('Make a guess: ')) while attempts > 0: if user == comp: return (f'your guess is right, Number:{comp}') if user > comp: print (f'Your guess is too high') print (f'You have {attempts} attempts Remaining') return (easy_or_hard()) if user < comp: print (f'Your guess is too low') print (f'You have {attempts} attempts Remaining') return (easy_or_hard()) return (f"You are out of guesses.. You lose Number is {comp}") comp = random.randrange(1,51) print('Welcomes to Guess a Number Game Let me think of a number between 1 to 50') level = input('Choose level of difficulty... Type(easy or hard): ').lower() if level == 'easy': attempts = 10 print (f'You have 10 attempts') print(easy_or_hard()) if level == 'hard': attempts = 5 print (f'You have 5 attempts') print(easy_or_hard())
Jenny makes me really sad to see that you don't post c++ as often... it would be so helpful to have the oop explained by someone as knowledge as you. don't think much about the views, maybe python gives a little bit more but someone that follows you would benefit much more with c++ because it can follow the c, c++ path, and then python. in the long run the views are gonna be the same or even more, but your channel becomes an even better reference given that it as all the foundational base. thank you so much, God bless you
Di are you doing this project on laptop on computer please please please please please please reply me ❤ by the way thank you 😊 and lots of love from uttrakhand ❤
import random print("GUESS THE NUMBER!") print("let me think of a number between 1 to 50.") computer_choice=random.randint(1,50) # print(computer_choice) choose_level=input("Choose level of difficulty...Type 'easy' or 'hard':") if choose_level=='easy': lives=10 print(f"you have {lives} attempts remaining to guess the number!") elif choose_level=='hard': lives=5 print(f"you have {lives} attempts remaining to guess the number!") end=False while not end: guess=int(input("Make a guess: ")) if lives==0: end=True print("you are out of guesses.. you lose!!") elif guess>computer_choice: print("your guess is too high!") print("guess again") lives-=1 print(f'you have {lives} attempts remaining to guess the number!') elif guess
import random level=input("type 'easy' or 'hard' to choose the level: ").lower() if level=="easy": print("you have 10 attempts to guess the number between 1 to 50") attempts=10 elif level=="hard": print("you have 5 attempts to guess the number between 1 to 50") attempts=5 else: print("invalid input") number=random.randint(1,50) print(number) print(level) while (level == "easy" and attempts > 0) or (level == "hard" and attempts > 0): guess=int(input("guess a number: ")) if guessnumber: print("too high") attempts-=1 print(f"you have {attempts} attempts left") else: print("u guessed it right") break
import random
num = random.randint(1,50)
diff_level=input("Enter the level of difficulty...Type 'easy' or 'hard': ")
if diff_level == "easy":
attempts = 10
print(f"Yor have {attempts} attempts to guess the number!")
elif diff_level == "hard":
attempts = 5
print(f"Yor have {attempts} attempts to guess the number!")
else:
print("Enter valid input!")
while (diff_level == "easy" and attempts > 0) or (diff_level == "hard" and attempts > 0):
guess = int(input("Make a guess: "))
if attempts == 0:
print("You lost")
elif guessnum:
print("Your guess is too high!")
attempts-=1
else:
print("Your guess is correct...You won!")
break
This code is easy one...
import random
import logo_art
def no_guesses(attempts,i):
if attempts - i != 0:
print('guess again')
return (f"you have {attempts - i} attempts remaining to guesses the number")
else:
return ('you are out of guesses,you lose!!')
def easy_hard(choose_num,attempts):
print(f"you have {attempts} attempts remaining to guess the number!")
for i in range(1,attempts + 1):
guess = int(input('make a guess'))
if guess > choose_num:
print('your guess is too high')
print(no_guesses(attempts,i))
elif guess < choose_num:
print('your guess is too low')
print(no_guesses(attempts,i))
else:
print(f'you guess is right...The answer was {choose_num}')
break
print(logo_art.logo)
print('let me think of a number between 1 to 50.')
num_list = list(range(51))
choose_num = random.choice(num_list)
while True:
level = input("Choose level of difficulty...Type 'easy' or 'hard' : ")
if level == 'easy':
easy_hard(choose_num,attempts = 10)
break
elif level == 'hard':
easy_hard(choose_num,attempts = 5)
break
else:
print("you've entered wrong input,Try again")
import random
level=input("type 'easy' or 'hard' to choose the level: ").lower()
if level=="easy":
print("you have 10 attempts to guess the number between 1 to 50")
attempts=10
elif level=="hard":
print("you have 5 attempts to guess the number between 1 to 50")
attempts=5
else:
print("invalid input")
number=random.randint(1,50)
print(number)
print(level)
while (level == "easy" and attempts > 0) or (level == "hard" and attempts > 0):
guess=int(input("guess a number: "))
if guessnumber:
print("too high")
attempts-=1
print(f"you have {attempts} attempts left")
else:
print("u guessed it right")
break
im glad i found this chanel!
from random import randint
from L import LOGO
print(LOGO)
print()
print("Think of a number between 1 to 50. ")
while True:
choice = input("Choose difficulty level... type 'easy' or 'hard': ").lower()
options = ['hard', 'easy']
if choice not in options:
print("Enter valid option")
else:
break
if choice == "hard":
count = 5
print(f"you have {count} attempt remaining to guess the number.")
else:
count = 10
print(f"you have {count} attempt remaining to guess the number.")
numbertoguess = randint(30, 40)
counter = False
guess = int(input("Make a guess: "))
while not counter:
if guess < numbertoguess:
print("Your guess is too low
Guess again")
count = count - 1
print(f"you have {count} attempt left")
elif guess > numbertoguess:
print("Your guess is too high
Guess again")
count = count - 1
print(f"you have {count} attempt left")
else:
print("Your guess is right... You win")
print(f"the number is {numbertoguess}")
break
if count == 0:
counter = True
print("You are out of guesses")
break
else:
guess = int(input("Make a guess: "))
Thank you so much for sharing knowledge ❤
import random
def guess_the_number_game():
print("Choose level of difficulty... Type 'easy' or 'hard':")
level = input().lower()
# Set number of attempts based on difficulty level
attempts = 10 if level == 'easy' else 5
number = random.randint(1, 100) # Random number between 1 and 50
print(f"You have {attempts} attempts remaining to guess the number!")
while attempts > 0:
guess = int(input("Make a guess: "))
if guess < number:
print("Your guess is too low.")
elif guess > number:
print("Your guess is too high.")
else:
print(f"Congratulations! You've guessed the number {number} correctly.")
break
attempts -= 1
if attempts > 0:
print(f"Guess again! You have {attempts} attempts remaining.")
else:
print(f"Sorry, you're out of attempts. The correct number was {number}.")
# Run the game
guess_the_number_game()
If we entered wrong difficulty to ask again we should call game() in if condition block
Perfect example of brain with beuty🫣
Racists
ap bhi kisi se km nhi ho
import random
print("guess the number")
computer_guessed=random.randint(1,50)
difficulty_level=input("enter a difficulty level 'hard' or 'easy':")
if difficulty_level=="easy":
print("you have 10 chances")
for i in range(1,10):
human_guessed_number=int(input("enter a no"))
if computer_guessed==human_guessed_number:
print("you are correct")
break
elif human_guessed_number>computer_guessed:
print("your guess is more")
elif human_guessed_number computer_guessed:
print("your guess is more")
elif human_guessed_number < computer_guessed:
print("your guess is low")
else:
print(f"try again {4-i}")
Easy to understand ....❤
Major steps involved in the code:
Import the necessary modules: random and logo_art.
Define constants for the number of attempts allowed for each difficulty level.
Define a function set_difficulty that takes the chosen level (‘easy’ or ‘hard’) and returns the corresponding number of attempts.
Define a function check_answer that compares the guessed number with the answer and provides feedback (too low, too high, or correct).
Define the main game function game:
Display a logo.
Generate a random number between 1 and 50 as the answer.
Ask the user to choose a difficulty level.
Set the number of attempts based on the chosen level.
Repeatedly prompt the user to guess a number:
Display the remaining attempts.
Check if the guessed number is correct or not.
Update the remaining attempts.
End the game if the user guesses correctly or runs out of attempts.
Nice project❤❤❤❤
Jenny Mam, Is there any book you follow for exercises that you make do, can you suggest me any website or book for more real time experience
i also learned python drom this channel
import random
print("Think a number between 1 to 50.")
number = random.randint(1, 50)
# print(number)
level = int(input("Choose level of difficulty...for 'easy' type (1) or for 'hard' type (2): "))
no_guess=0
def num(level):
if level==1:
global no_guess
no_guess = 10
elif level==2:
no_guess = 5
num(level)
while no_guess>=1:
print(f"You have {no_guess} attempts remaining to guess the no.")
guess = int(input("Make a guess: "))
if guess>number:
no_guess -= 1
print("Your Guess is Too high.")
elif guess=1:
print("Guess again!")
if no_guess==0 and guess!=number:
print("You Lose the Game...☹☹!!")
import random
print("guess the numbers from 1 to 100:" )
answer = random.randint(1,100)
choose_level = input("choose level of difficulty Type 'easy' or 'hard': ")
if choose_level == 'easy':
print("you have 10 attempts to guess the number:" )
attempts = 10
while attempts>0:
guess_number = int(input(" enter the guess number:"))
if guess_number == answer:
print(f"your guess number {guess_number} is correct you won")
break
elif guess_number < answer:
print("your guess is low:")
attempts = attempts-1
if attempts == 0:
print("you lost")
else:
print(f"guess again and you have {attempts} attempts only")
elif guess_number > answer:
print("your guess is high:")
attempts = attempts-1
if attempts == 0:
print("you lost")
else:
print(f"guess again and you have {attempts} attempts only")
elif choose_level == 'hard':
print("you have 5 attempts to guess the number:")
attempts = 5
while attempts>0:
guess_number = int(input(" enter the guess number:"))
if guess_number == answer:
print(f"your guess number {guess_number} is correct and won")
break
elif guess_number < answer:
print("your guess is low:")
attempts -= 1
if attempts == 0:
print("you lost")
else:
print(f"guess again and you have {attempts} attempts only" )
elif guess_number > answer:
print("your guess is high:")
attempts -= 1
if attempts == 0:
print("you lost")
else:
print(f"guess again and you have {attempts} attempts only" )
else:
print(" you have entered wrong level name and select proper level")
"""Guess the no"""
import random
print("guess the no")
randomno=random.randint(1,30)
print(randomno)
level=1
user_level=input("which level you want easy/hard")
chances = 10
hard_chance=5
def diffrence(a,b):
newone=range(a,b)
if len(newone)>=1 and len(newone)11 and len(newone) 21 and len(newone)
import random
answer = random.randint(1,50)
level = input("Choose your level (Easy / Hard): ").lower()
if level == 'easy':
chances = 10
elif level == 'hard':
chances = 5
while True:
user = int(input("Enter a number between 1 and 50: "))
if user == answer:
print(f"{user} is the correct guess. You won!")
break
elif user > answer:
print("Your guess is too high")
chances -= 1
if chances > 0:
print(f"You have {chances} attempts left")
else:
print("You have no attempts left. You lose!")
break
else:
print("Your guess is too low")
chances -= 1
if chances > 0:
print(f"You have {chances} attempts left")
else:
print("You have no attempts left. You lose!")
break
Mam .....when will you upload the c++ programming language...... please post that mam❤😮
# Assignment answer :- Ask level again, when we mistakenly typed wrong Difficulty level.
print(num_logo.logo)
print("Let me think of a number beetween 1 to 50.")
answer= random.randint(1,50)
def game():
level= input("Choose level of Difficulty--> Type 'easy' or 'hard'=").lower()
attempts= set_difficulty(level)
if attempts!= EASY_LEVEL_ATTEMPT and attempts!= HARD_LEVEL_ATTEMPT:
print("You have entered wrong difficulty level, Play Again!")
return game()
i did this but it was too simple... even these beginner projects are too hard for me
Ma'am when this python course will complete
Long live ur lecture mam
This project is mentioned in resume
import random
def guess_game(num,level):
if level=='hard':
count=5
else:
count=10
flag=True
i=0
while inum:
print("Its too high")
print("Guess Again")
elif guess
import random
attempts = 0
def easy_or_hard():
global attempts
attempts -= 1
user = int(input('Make a guess: '))
while attempts > 0:
if user == comp:
return (f'your guess is right, Number:{comp}')
if user > comp:
print (f'Your guess is too high')
print (f'You have {attempts} attempts Remaining')
return (easy_or_hard())
if user < comp:
print (f'Your guess is too low')
print (f'You have {attempts} attempts Remaining')
return (easy_or_hard())
return (f"You are out of guesses.. You lose
Number is {comp}")
comp = random.randrange(1,51)
print('Welcomes to Guess a Number Game
Let me think of a number between 1 to 50')
level = input('Choose level of difficulty... Type(easy or hard): ').lower()
if level == 'easy':
attempts = 10
print (f'You have 10 attempts')
print(easy_or_hard())
if level == 'hard':
attempts = 5
print (f'You have 5 attempts')
print(easy_or_hard())
but why cant I write break in while loop instead of return
Kash apka channel class 12 me mil jata. 😢
Ab toh boards bhi khatam ho gye
Jenny makes me really sad to see that you don't post c++ as often... it would be so helpful to have the oop explained by someone as knowledge as you. don't think much about the views, maybe python gives a little bit more but someone that follows you would benefit much more with c++ because it can follow the c, c++ path, and then python. in the long run the views are gonna be the same or even more, but your channel becomes an even better reference given that it as all the foundational base. thank you so much, God bless you
arre bhai itna emotional nhi hote 🤣 agar itna hi padhna hota to youtube pe itni saari video h, udhar se kr leta :)
Guess Number is always changing if we are unable to guess.
Showing error in game()
Please send the code of this project
Di are you doing this project on laptop on computer please please please please please please reply me ❤ by the way thank you 😊 and lots of love from uttrakhand ❤
Laptop 💻
Thankyou for replying ❤️
80✅
In which aap you are doing
can you share your github id or somehow add your code in the description or comment section or telechannel
Ye course kitna din lagega aur
import random
print("GUESS THE NUMBER!")
print("let me think of a number between 1 to 50.")
computer_choice=random.randint(1,50)
# print(computer_choice)
choose_level=input("Choose level of difficulty...Type 'easy' or 'hard':")
if choose_level=='easy':
lives=10
print(f"you have {lives} attempts remaining to guess the number!")
elif choose_level=='hard':
lives=5
print(f"you have {lives} attempts remaining to guess the number!")
end=False
while not end:
guess=int(input("Make a guess: "))
if lives==0:
end=True
print("you are out of guesses.. you lose!!")
elif guess>computer_choice:
print("your guess is too high!")
print("guess again")
lives-=1
print(f'you have {lives} attempts remaining to guess the number!')
elif guess
anyone have a sample of a flowchart?
👉👉Ma'am aapka Ghar kanha hai
Ma'am aap please Hindi language me bol ke padhaye English language me problem hota hai
Assam, Guwahati, should I book your ticket to go there ?
I'm confused... To observe the lesson or to admire your beauty? Thank yewww new mam !
Hii mam
Do Java course
import random
level=input("type 'easy' or 'hard' to choose the level: ").lower()
if level=="easy":
print("you have 10 attempts to guess the number between 1 to 50")
attempts=10
elif level=="hard":
print("you have 5 attempts to guess the number between 1 to 50")
attempts=5
else:
print("invalid input")
number=random.randint(1,50)
print(number)
print(level)
while (level == "easy" and attempts > 0) or (level == "hard" and attempts > 0):
guess=int(input("guess a number: "))
if guessnumber:
print("too high")
attempts-=1
print(f"you have {attempts} attempts left")
else:
print("u guessed it right")
break