Guess the Number Beginner Python Tutorial | Learning Python for Beginners | Code with Kylie #8

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

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

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

    I'm so impressed how a simple script could be related to a principle of machine learning such as the second one.
    Some add-ons and the function might be able to check it's performance and improve it.
    Awesome. Thank you so much for this video.

  • @PigLover90
    @PigLover90 Месяц назад

    Thank you for helping me do my CS HW better than my Professor explains stuff...

  • @elementour
    @elementour 3 года назад +4

    I was working through this and was pleased when I got it working so I showed my girlfriend my work and the first thing she did was break it by pressing a different key!. I then had to spend time working out how to do some exception handling which takes me a while given im a complete novice to coding. That's twice she has done it now lol. I'm really enjoying your vid's though and they are helping me learn the basics

  • @teacherinthailan6441
    @teacherinthailan6441 3 года назад +3

    Excellent tutorial. You are an awesome teacher. Thank you so much.

  • @vaishaligatla8905
    @vaishaligatla8905 2 года назад +1

    Hey Kylie how can I add points when we guess.
    Example: A person is playing a guessing game in which they have 3 guesses to figure out the computer's secret number which will be between 1 and 20 inclusive (use randint to generate the number).If they guess the number correctly on the first guess the program should stop making them guess and they should get 10 points.
    If they guess the number correctly on the second guess the program should stop making them guess and they should get 5 points If they guess the number correctly on the third guess, they should get 1 point. After an incorrect guess tell the user if their guess was too high or too low. If they fail to get the number correct after 3 guesses they get 0 points. Be sure to tell them what score they got, and show the computer's secret number. Ask the user if they want to continue playing the game. If they choose to play again, start at the beginning. If not, print a farewell message and the user's total score.
    Can you please help me to explain how to add points and give chances.
    I will be waiting for your reply.
    Thank you.

  • @brianhourihan2285
    @brianhourihan2285 4 года назад +5

    Hi, Thanks for the tutorials as they are very helpful for beginners like me. I wanted to add giving the computer limited guesses. I tried creating a variable called count before the while loop and set it to zero. Then I set the conditions of the while loop to include your conditions in the video plus another "and" statement where count must be less than 4. Then after the if/else statements that you made I put count += 1 so the loop would terminate if it got above four. But I couldn't figure out how to make it print a message like "I didn't guess correctly" because the function would print that same message even if I hit c. I tried indenting, but it didn't work. I don't know if you understand me or not because it hard to explain in a RUclips comment and I'm a total newb. Thanks.

    • @KylieYYing
      @KylieYYing  4 года назад +3

      If I understand what youre saying correctly, you want to print out a different statement saying you’ve hit the limit. You would likely have to put in an if statement at the very end outside the loop to see whether the loop terminated as a result of incorrect guesses or because you’ve guessed the correct word

  • @bengharsaeya2856
    @bengharsaeya2856 2 года назад +1

    in the first part do we have to make a function?

  • @avimehta9355
    @avimehta9355 2 года назад +1

    Thank you! Helped a lot.

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

    Wow, the second one was harder lol but I did it. 🎉

  • @marielosjauregui9065
    @marielosjauregui9065 2 года назад

    new sub! loved your vid you the way you pull up definitions! you diamond!

  • @Seervan
    @Seervan 2 года назад +1

    Thanks for the good content!
    I'm not sure what is the problem but when I add the ".lower" part to the last part of the feedback parameter, the code just reiterates. But when I deleted it it just worked fine.

    • @MuederDaemon
      @MuederDaemon 2 года назад

      found the same problem "feedback = input(f"Is {guess} too high (H), too low(L), or correct (C)?? ").lower()" the () at the end are integral or it wont work

  • @Dopamineaddict
    @Dopamineaddict 2 года назад

    I keep getting my output stuck on guess the number between 1 to 10 and like you did at 3:59 and even when the code was completed at 6:22 it does the same thing it doesn't print low or high

    • @mr.zero-zone
      @mr.zero-zone 2 года назад

      check the last line of code. if you are calling the first function then call the second function.
      according to this video, 1st function is calling on the last line guess(10), to guess the user secret number by the computer you should call the second function is computer_guess(10)

  • @YM-lm8xr
    @YM-lm8xr 3 года назад

    i think you left out the explanation on "f string", could you specify that if possible?

  • @BECGAURAVNARULA
    @BECGAURAVNARULA 2 года назад +1

    The first part of running the code is not working. Does anyone have any idea and yes I actually copied the code right but it isn't working it's applying the upper bound of 10 on x . Any suggestions?

    • @BECGAURAVNARULA
      @BECGAURAVNARULA 2 года назад

      No issues once the code got updated it went right through thank you for these videos.

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

      Hello, I seem to have the same problem, howd u do it?

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

      @@francogarcia8401 try closing the whole application and then open to run again or you know copy the right code that you have written and paste it in another window to run again. Hopefully it will work.

  • @kevinfinkel5536
    @kevinfinkel5536 2 года назад

    What does it mean when the f function doesn't change color in the line to determine the correct number?

  • @lukasbohunicky1679
    @lukasbohunicky1679 2 года назад

    Hellou ,is ther any way that if i accidently put letter as and aswear for question guess the number can i print something like "this is not the numnber"?

  • @serracengiz86
    @serracengiz86 2 года назад +1

    i don’t get "guess = 0" part. is it needed? why is it there?

  • @jakesteffan1581
    @jakesteffan1581 2 года назад

    The end of the video. 🤣🤣🤣

  • @Vijay_helo
    @Vijay_helo 3 года назад

    Thank you very much sister. you really helped me for my SCHOOL PROJECT! as well as the VIVA coz you just not give simply any programme. You explain it and make it very easy! Thank you ... and a hifi😊

  • @yonesmith2867
    @yonesmith2867 3 года назад

    i need help fixing this
    import random
    name = input('Enter your name human')
    age = input('Enter your age' + name)
    answer = input('Ok ' + name + ' Lets play a game, think of a number and type ok when ready')
    if answer == 'ok':
    def computer_guess(x):
    low = 1
    high = x
    feedback = ''
    while feedback != 'c':
    if low != high:
    guess = random.randint(low, high)
    else:
    guess = low
    feedback = input(f'Is {guess} too high(h), too low(l). or correct (c) ??')
    if feedback == 'h':
    high = guess -1
    elif feedback =='l':
    low = guess + 1
    print('Yay i guessed your number, {guess), right!')

    • @ramceesgonzalez5785
      @ramceesgonzalez5785 2 года назад

      Hey there, you had a few indentation problems in line 1 and the last line.
      After that, you also created a function, but then never called it. So you'd need to add the function name on line 21 or after.
      Your final print also has an issue where you forgot to add an 'f' at the beginning and you didn't close the accolade.
      Also, your questions are missing spaces.
      Here's your code with the said fixes. I didn't add anything else to optimize. Just fixed what your wrote.
      import random
      name = input('Enter your name human ')
      age = input('Enter your age ' + name)
      answer = input('Ok ' + name + ' Lets play a game, think of a number and type ok when ready ')
      if answer == 'ok':
      def computer_guess(x):
      low = 1
      high = x
      feedback = ''
      while feedback != 'c':
      if low != high:
      guess = random.randint(low, high)
      else:
      guess = low
      feedback = input(f'Is {guess} too high(h), too low(l). or correct (c) ??')
      if feedback == 'h':
      high = guess -1
      elif feedback =='l':
      low = guess + 1
      computer_guess(50)
      print(f'Yay i guessed your number, {guess}, right!')

  • @dnels4870
    @dnels4870 3 года назад

    Hey Kylie! I know this was a year ago at this point, and maybe that's the issue as is, but my VS code doesn't recognize the 'import random' command. Do you have to take any additional steps for it to recognize the 'random' package? Thank you!

    • @memeruler6146
      @memeruler6146 2 года назад

      Tbh it should work if you have python installed

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

      You should install random module first and then try it.

  • @BM-un4os
    @BM-un4os 3 года назад +1

    tried this and it didnt work, watched another video online, and think you need to add a int(input()) in the while loop after Print, no? I wasnt prompted to guess again trying your way

  • @simonreliy6990
    @simonreliy6990 2 года назад +1

    Guess the number between 2 and 4

  • @seanjames1626
    @seanjames1626 4 года назад

    Great Video, Tyvm!

  • @natemagliano2192
    @natemagliano2192 3 года назад

    Could you try this but using a for loop?

    • @KylieYYing
      @KylieYYing  3 года назад

      sure, if you only want a certain number of guesses

  • @kindlycode7947
    @kindlycode7947 3 года назад +2

    ez cheat on my project♥

  • @javhaasuhochir8126
    @javhaasuhochir8126 2 года назад

    oh the computer_guess function is so hard to understand

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

    I miss u

  • @jitendersingh-ju8bz
    @jitendersingh-ju8bz 2 года назад

    gr8

  • @RONYHAZARIKA
    @RONYHAZARIKA 4 года назад

    Great Job , Kylie!! bdw I tried making a tic tac toe game but i can't get the board to clear out and restart a new game when i tried to define a function for looping back to the game.

    • @KylieYYing
      @KylieYYing  4 года назад

      likely you'll need to reset the game board variable and reinitialize it

  • @unkownnn6664
    @unkownnn6664 4 года назад

    Hi do u remember me . My computer broke so i cant code . Please can u tell me apps that i can u on my phone like python ..
    Btw thanks for being teaching me how to code

    • @KylieYYing
      @KylieYYing  4 года назад

      I'm not sure if there are any apps that will let you code on your phone. I'm unfamiliar with coding from a cell phone.. You can try searching on google but I would highly recommend fixing the computer :/

    • @stringtra4531
      @stringtra4531 4 года назад

      @@KylieYYing I think Google collab could work on phones...

  • @usmonbekravshanov6933
    @usmonbekravshanov6933 3 года назад

    You look stunning)

  • @notAvn
    @notAvn 2 года назад

    omg you're so cute 😳

  • @khubaibmohamed4418
    @khubaibmohamed4418 3 года назад

    Your so beautiful

    • @XxXK9
      @XxXK9 3 года назад

      Creep