Python Project for beginners #7| Guess The Number -Complete Code | Python for Beginners

Поделиться
HTML-код
  • Опубликовано: 2 дек 2024

Комментарии • 52

  • @vaishnavisharma5728
    @vaishnavisharma5728 5 месяцев назад +5

    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

  • @Shantanu_lrnr
    @Shantanu_lrnr Год назад +4

    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")

  • @bharath-v7z
    @bharath-v7z 9 месяцев назад +2

    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

  • @inkbythebarrelandpaperbyth6905
    @inkbythebarrelandpaperbyth6905 10 месяцев назад +1

    im glad i found this chanel!

  • @chinenyeumeaku9262
    @chinenyeumeaku9262 Год назад +1

    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: "))

  • @vasanthkumar3567
    @vasanthkumar3567 Год назад +5

    Thank you so much for sharing knowledge ❤

  • @padalasantosh8829
    @padalasantosh8829 2 месяца назад +1

    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()

  • @shivakrishna_varma9658
    @shivakrishna_varma9658 2 месяца назад

    If we entered wrong difficulty to ask again we should call game() in if condition block

  • @digi_aayu
    @digi_aayu Год назад +13

    Perfect example of brain with beuty🫣

  • @DARK_RYZEN
    @DARK_RYZEN 11 месяцев назад +1

    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}")

  • @muneebbolo
    @muneebbolo 8 месяцев назад

    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.

  • @sayednoorahmad8973
    @sayednoorahmad8973 Год назад +1

    Nice project❤❤❤❤

  • @vinodkumarpunna1163
    @vinodkumarpunna1163 4 месяца назад +1

    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

  • @pythonassignment
    @pythonassignment Год назад

    i also learned python drom this channel

  • @nikhils__2808
    @nikhils__2808 23 дня назад

    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...☹☹!!")

  • @-kunchalaAjay
    @-kunchalaAjay 3 месяца назад

    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")

  • @iam-irfan
    @iam-irfan 2 месяца назад

    """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)

  • @adityakhare7100
    @adityakhare7100 7 дней назад

    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

  • @Lekshmi_sree
    @Lekshmi_sree Год назад +1

    Mam .....when will you upload the c++ programming language...... please post that mam❤😮

  • @adamyagogreen
    @adamyagogreen Год назад

    # 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()

  • @lolabunny9669
    @lolabunny9669 4 месяца назад

    i did this but it was too simple... even these beginner projects are too hard for me

  • @puneethreddymreddy1510
    @puneethreddymreddy1510 Год назад +1

    Ma'am when this python course will complete

  • @prabhuns1791
    @prabhuns1791 Год назад

    Long live ur lecture mam

  • @anurajyendhe5981
    @anurajyendhe5981 Год назад

    This project is mentioned in resume

  • @MonicaManimaran
    @MonicaManimaran 10 месяцев назад

    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

  • @رينشاد_أ
    @رينشاد_أ 6 месяцев назад

    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())

  • @k.v.rohithsai2495
    @k.v.rohithsai2495 23 дня назад

    but why cant I write break in while loop instead of return

  • @harryjamespotter9437
    @harryjamespotter9437 8 месяцев назад

    Kash apka channel class 12 me mil jata. 😢
    Ab toh boards bhi khatam ho gye

  • @eumm11
    @eumm11 Год назад +6

    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

    • @benstokes75499
      @benstokes75499 Год назад +1

      arre bhai itna emotional nhi hote 🤣 agar itna hi padhna hota to youtube pe itni saari video h, udhar se kr leta :)

  • @srinivasaraovooda
    @srinivasaraovooda Год назад

    Guess Number is always changing if we are unable to guess.

  • @KavitaPatel-wo4yj
    @KavitaPatel-wo4yj Год назад +1

    Please send the code of this project

  • @purpledreamers618
    @purpledreamers618 Год назад

    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 ❤

  • @shiv_gourav
    @shiv_gourav 4 месяца назад

    80✅

  • @diusdance7891
    @diusdance7891 3 месяца назад

    In which aap you are doing

  • @sujinas2434
    @sujinas2434 Год назад

    can you share your github id or somehow add your code in the description or comment section or telechannel

  • @sandipanpasari7017
    @sandipanpasari7017 Год назад

    Ye course kitna din lagega aur

  • @rathnakar3h131
    @rathnakar3h131 9 месяцев назад

    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

  • @yeoshuabenzaken7736
    @yeoshuabenzaken7736 4 месяца назад

    anyone have a sample of a flowchart?

  • @softmedun6794
    @softmedun6794 Год назад +1

    👉👉Ma'am aapka Ghar kanha hai
    Ma'am aap please Hindi language me bol ke padhaye English language me problem hota hai

    • @adamyagogreen
      @adamyagogreen Год назад +1

      Assam, Guwahati, should I book your ticket to go there ?

  • @trichyboys2667
    @trichyboys2667 Год назад

    I'm confused... To observe the lesson or to admire your beauty? Thank yewww new mam !

  • @TeluguDisciplineGamers
    @TeluguDisciplineGamers Год назад

    Hii mam

  • @pranaybattu5169
    @pranaybattu5169 Год назад

    Do Java course

  • @SarathReddyKakarla
    @SarathReddyKakarla 3 месяца назад

    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