Number Guessing Game | Python Example

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ต.ค. 2024

ความคิดเห็น • 46

  • @PortfolioCourses
    @PortfolioCourses  ปีที่แล้ว +2

    Check out these Python playlists too with 100+ similar videos... 🙂
    Python Tutorials (concepts): th-cam.com/play/PLA1FTfKBAEX73xlgzMb4jzjBSCGp0Rpto.html
    Python Examples (exercises): th-cam.com/play/PLA1FTfKBAEX40W8OeycI8S5ltunvS8CWw.html

  • @soliez0xff
    @soliez0xff ปีที่แล้ว +12

    See now this easily made sense, thank you for explaining each step in your program’s execution in such a calculated concise manner, it actually felt like i was reading from a an actual workflow i had created whereas the rubric my professor provided felt intentionally obfuscated

    • @PortfolioCourses
      @PortfolioCourses  ปีที่แล้ว +2

      I'm glad it easily made sense for you, and you're welcome! :-)

  • @kyyzh12
    @kyyzh12 7 หลายเดือนก่อน +3

    Very understandable tutorial! I actually understood everything you said

  • @santhoshsathish5828
    @santhoshsathish5828 9 หลายเดือนก่อน +1

    Thank you for this amazing video.. It really helped me out for my board practical’s ❤

  • @sairaj2259
    @sairaj2259 ปีที่แล้ว +5

    Thanks! it really helped me understand the loops better.

    • @PortfolioCourses
      @PortfolioCourses  ปีที่แล้ว

      You're welcome, I'm glad to hear it helped you out! :-)

  • @hem.lock._
    @hem.lock._ ปีที่แล้ว +2

    Thank you so much from this I understood how while loops work I've subbed

    • @PortfolioCourses
      @PortfolioCourses  ปีที่แล้ว

      You're welcome, I'm glad this video was able to help you understand while loops, and welcome aboard! :-)

  • @fryaldraws6294
    @fryaldraws6294 6 หลายเดือนก่อน

    Thank you, this was really helpful.
    But you forgot to let the user know how much guesses they have guessed...

  • @Saudi-Ball
    @Saudi-Ball ปีที่แล้ว +2

    I want to put pictures in the questions but how??

  • @Ice_2192
    @Ice_2192 7 หลายเดือนก่อน

    I did a little more and added an attempt counter. Every time I took a guess the counter goes up and at the end of the game it says how many tries it took to guess the correct number.

  • @Metrojo831
    @Metrojo831 ปีที่แล้ว +1

    thanks
    i really needed this
    so thank you so much

    • @PortfolioCourses
      @PortfolioCourses  ปีที่แล้ว +1

      You're very welcome, I'm glad that it was helpful! :-)

  • @helenodili2360
    @helenodili2360 11 หลายเดือนก่อน +1

    How do you make the program to give the user a limited amount of guesses then prints "Game over" after he reaches the limit

    • @Ratamos6
      @Ratamos6 9 หลายเดือนก่อน +2

      Idk if you found the answer for this but i did it in that way:
      Attempts = 0
      While guess != number
      Attempts += 1
      If (attempts > 10)
      print(Game over)
      break

  • @RICHAPal-qe2ve
    @RICHAPal-qe2ve 8 หลายเดือนก่อน

    Sorry Sir but I can't understand why it stopped at 75 and told us that you want

  • @yivett
    @yivett 11 หลายเดือนก่อน

    I’ll be trying this out today! I have python downloaded but to do my scripts I use Visual Studio Code because I wasn’t able to get my python working with my own terminal from my MacBook. Would I write the game on Visual and guess it with IDLE or my terminal? Sorry I’m a beginner 😬

  • @tASBIDTASEENAHMED
    @tASBIDTASEENAHMED 4 หลายเดือนก่อน

    i love this informative video. pls make more. Thank u love you so much!! This have me new ideas. Please remember my name as i might come to see you soon. ttyl!!! xoxo

  • @CoderMala
    @CoderMala 6 หลายเดือนก่อน

    Thank you so much

  • @LoujinaLoujian
    @LoujinaLoujian 2 หลายเดือนก่อน

    WHICH SITE DID YOU USE

  • @trestonnemisz9866
    @trestonnemisz9866 ปีที่แล้ว +1

    What if I told you I put this on my calculator

    • @PortfolioCourses
      @PortfolioCourses  ปีที่แล้ว

      Haha I would say that's awesome Treston! :-) I would actually like to see that.

  • @DeathRebel369
    @DeathRebel369 ปีที่แล้ว

    How would you loop back to the user input prompt if they type in a string instead of an integer?

    • @adriellyaraujo2354
      @adriellyaraujo2354 11 หลายเดือนก่อน

      I wanna know this too, have you found the answer already?

    • @brightkaponda5110
      @brightkaponda5110 8 หลายเดือนก่อน +1

      int(input) you can use try and catch block to catch the error .

  • @kristnajohanna
    @kristnajohanna 8 หลายเดือนก่อน

    Thank you! / Sweden

  • @Darkdragon-dp8ud
    @Darkdragon-dp8ud ปีที่แล้ว

    mine says unexpected syntax error for the if guess < number code

    • @PortfolioCourses
      @PortfolioCourses  ปีที่แล้ว

      The source code for this video is available here, it should work: github.com/portfoliocourses/python-example-code/blob/main/number_guessing_game.py. Maybe the : is missing? Or maybe it's an indentation issue? This video covers indentation in Python: th-cam.com/video/CcgSYrWwSpE/w-d-xo.html

  • @yhaiji
    @yhaiji 19 วันที่ผ่านมา

    thanks

  • @TakundamusiiwaMusiiwa
    @TakundamusiiwaMusiiwa 3 หลายเดือนก่อน

    You are the best

  • @gedeonaziagbe6231
    @gedeonaziagbe6231 ปีที่แล้ว +1

    thank you

  • @ARD105
    @ARD105 ปีที่แล้ว

    What does the ! Mean in the while loop, it doesn’t work without it, what does it do???

    • @PortfolioCourses
      @PortfolioCourses  ปีที่แล้ว

      The ! is part of an operator !=, it means "does not equal". So if the guess "does not equal" the number then the loop will continue because the loop condition will be true. :-)

    • @ARD105
      @ARD105 ปีที่แล้ว

      @@PortfolioCourses that makes sense, thank you

    • @PortfolioCourses
      @PortfolioCourses  ปีที่แล้ว

      You're welcome! :-)

  • @beautywow7520
    @beautywow7520 ปีที่แล้ว

    Hi idk but it isnt printing the guess lower thing at all idk why

    • @PortfolioCourses
      @PortfolioCourses  ปีที่แล้ว

      I’m not sure why that would happen. The original code for this video is here: github.com/portfoliocourses/python-example-code/blob/main/number_guessing_game.py. Do you still get the error if you try using exactly that code? :-)

    • @pepedafrog2277
      @pepedafrog2277 ปีที่แล้ว +1

      make sure the if, elif, and else statements are inside the while loop, by indenting them

  • @nikola---123
    @nikola---123 6 หลายเดือนก่อน

    Thanks bro

  • @trapsama892
    @trapsama892 ปีที่แล้ว

    How do you make it so that if the user enters a number outside of the 1-100 range it tells the user to enter a new number?

    • @PortfolioCourses
      @PortfolioCourses  ปีที่แล้ว +6

      You could do something like this:
      if (guess < 1 or guess > 100):
      print("Number must be between 1-100, please guess again")
      elif (guess < number):
      print("Guess higher!")
      elif (guess > number):
      print("Guess lower!")
      else:
      print("You won!")