How to code Rock Paper Scissors (Beginner Python Tutorial)

  Рет қаралды 72,231

Kylie Ying

Kylie Ying

Күн бұрын

Пікірлер: 137
@AmjadGD
@AmjadGD 4 жыл бұрын
Me:copying all what she did Also me:im programr
@rubyshekhar2869
@rubyshekhar2869 3 жыл бұрын
I think you are a pro-gamer
@dbducks9697
@dbducks9697 3 жыл бұрын
@Vincent Ludwig XDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
@ryanschmutzler5291
@ryanschmutzler5291 2 жыл бұрын
I just started learning python and this really helped me understand statements and functions
@shinkansen1907
@shinkansen1907 4 жыл бұрын
Hi Kylie, these projects really helping me a lot! You are the big champ!
@paraglide01
@paraglide01 2 жыл бұрын
Thank you very much, I learned a lot. The "return (0,user,computer)" statement was an eye opener for me. I can see the potential in this.
@johnuthus
@johnuthus 4 жыл бұрын
Ah my first program (i skipped hello world)
@KylieYYing
@KylieYYing 4 жыл бұрын
Good one!
@johnuthus
@johnuthus 4 жыл бұрын
@@KylieYYing wheres my program on how to talk to girls
@ItsStitchyWasTaken
@ItsStitchyWasTaken 3 жыл бұрын
@@johnuthus you just did :D
@johnuthus
@johnuthus 3 жыл бұрын
@@ItsStitchyWasTaken then how am I single?
@ItsStitchyWasTaken
@ItsStitchyWasTaken 3 жыл бұрын
@@johnuthus uhm 😶 you talked to the wrong women :D
@pronglebot
@pronglebot 4 жыл бұрын
lmao you said tic tac toe at 8:07, i'm only pointing this out because i was making a rock paper scissors game as well mine is much more basic compared to this one and i kept referring to it as tic tac toe instead of rock paper scissors, good video tho its nice to see other iterations of the same game
@KylieYYing
@KylieYYing 4 жыл бұрын
Hahaha yeah I keep getting them mixed up even though they’re totally different
@HTWwpzIuqaObMt
@HTWwpzIuqaObMt 2 жыл бұрын
Instead of using random to select a random move, i thought of a strategy that the ai can follow to win. If we have a triangle with rock on top at bottom right the paper and at bottom left the scissors, if we lose from rock we can play the next move on the triangle which is paper and we won! Same for every other move. We can use the random lib to select a first move.
@Kaori--
@Kaori-- 2 жыл бұрын
3:53 uhmm, I would like to ask about running the script, how did you do that?
@Raj_2904
@Raj_2904 4 жыл бұрын
import random option = ['rock', 'paper', 'sci'] n = 0 m = 0 print ("Welcome to Rock-Paper-Scissor!") while n
@Raj_2904
@Raj_2904 4 жыл бұрын
Can you explain what this line does? (I dont get the 'main' part) if __name__ == '__main__': play_best_of(3) # 2
@smalltamm8264
@smalltamm8264 4 жыл бұрын
That is basically starting the function play, watching a separate youtube video for it would give the best explanation but basically "if the name of the file is main then run the play function"
@fertwvnbxcbwrtrecvbvcx
@fertwvnbxcbwrtrecvbvcx 3 жыл бұрын
This is (in my opinion) a concept that's too advanced for beginners. You should be fine for now without it. Come back later when you have learned more about other parts of Python. This happens to me all the time too, you'll get used to it in programming.
@notseen6240
@notseen6240 3 жыл бұрын
For me it says '_name_' is not defined, anyone know how to help with that? ( I'm doing it through trinket)
@lordxauce007
@lordxauce007 2 жыл бұрын
GURL....THANK YOU FOR GETTING TO THE POINT.
@aliway7037
@aliway7037 2 жыл бұрын
I’m able to run the program but it isn’t acknowledging a winner, only what the computer chose. I typed everything you did, is there a broader explanation around the losses?
@Mohamedtarek-qz2zj
@Mohamedtarek-qz2zj 4 жыл бұрын
Great, short and Simple tutorial, Thank you
@tmate88-j8y
@tmate88-j8y Жыл бұрын
Very fun video! Thanks for sharing it!
@BradleyRaines
@BradleyRaines 8 ай бұрын
What class did you learn this game program from Kylie ?
@bcf_
@bcf_ 3 жыл бұрын
Cool video, did you know why when I return string like you ( Return 'It\'s a tie' ) for example. The terminal shows nothing (but it works with a classical print) ?
@yorick9053
@yorick9053 4 жыл бұрын
For me it says: name 'math' is not defined. Could you help me. Its on line 31.
@yorick9053
@yorick9053 4 жыл бұрын
Sry, I found the solution. Just missed 'import math' on line 2. Great video and it works for me! thanks!
@mosammatmuntaha7645
@mosammatmuntaha7645 3 жыл бұрын
I just started learning this programming language and want to practice it practically. Where can I download this version of python from?
@quantumaraa169
@quantumaraa169 3 жыл бұрын
Sublime text is useful. This is just python ide u can download it online.
@olivialoveroy2868
@olivialoveroy2868 2 жыл бұрын
visual studio code . she is using visual studio code, it might help you and also you should follow a step by step video
@ecptavares
@ecptavares 4 жыл бұрын
at line 47 of your code you used .format(n) where does this n come from? What is it? Thank you
@BrendanMetcalfe
@BrendanMetcalfe 3 жыл бұрын
Awesome project idea!
@blaqbrane8166
@blaqbrane8166 2 жыл бұрын
What if the player enters an invalid input? What happens and how do you include it in your code
@LeeMynx
@LeeMynx 3 жыл бұрын
may I ask what does line 10 .format(computer) means thank you
@hbarsogay
@hbarsogay 4 жыл бұрын
What will be better method to use when there are many possibilies. We cant keep adding on the condition check right? Thanks in advance ky
@KylieYYing
@KylieYYing 4 жыл бұрын
Good question. I think it depends what you’re conditioning on. There are some times where you have to condition check and have a lot of “Elif”s. In other languages, there’s even this case/switch things that is for this but python just uses if/elif/else: www.w3schools.com/js/js_switch.asp But other times you might be able to map your condition to a value in a dictionary let’s say. For example: {(paper, scissors): False, (paper, rock): True, ....} Sometimes there is no super clean way of implementing things.. and there’s usually a million different ways you can implement the same logic. Sometimes it’s at the discrestion of the engineer which one is the least ugly :’)
@hbarsogay
@hbarsogay 4 жыл бұрын
@@KylieYYing it is really awesome of u for taking time to responding questions. Wish u all the great success and would love to keep in touch. c = moc.liamg@liafreven.epoh Print(c[::-1])
@john-paulmatenga4943
@john-paulmatenga4943 3 жыл бұрын
I'm a noob and have been teaching myself python through various online resources. I attempted this project as my first solo build. I failed badly and came across this video. Is it normal to feel like I know nothing lol!
@KylieYYing
@KylieYYing 3 жыл бұрын
Yep, keep practicing! It's not supposed to be easy! It's a learning process
@alucardmax4891
@alucardmax4891 3 жыл бұрын
This code is super easy to read and your explanation is on point! thank you!!
@lolman6976
@lolman6976 2 жыл бұрын
it says this have any ideas "return" can be used only within a function
@p3nx1lz91
@p3nx1lz91 3 жыл бұрын
Thanks Kylie
@lordphemstar
@lordphemstar 2 жыл бұрын
You didn't add a while statement that check a wrong input from the user and returns error wrong input.. Try again.. Even at entering of the wrong letter T.. It still goes on playing the game
@hichewy6748
@hichewy6748 4 жыл бұрын
Sorry I'm a beginner. I don't understand the lines below. If you can tell me some terms I need to study for. Let me know, thanks very much!: line 11: return (0, user, computer) #? how can you have 3 items inside? and what does 0 mean here? line 15: return (1, user, computer) #? similiar to above. __________ line23: return True return False i assume it's same as below? return True else: return False line 33: result, user, computer = play() ?three items again? what does it mean? Also result doesn't need to be defined ?
@KylieYYing
@KylieYYing 4 жыл бұрын
The return is a tuple (check out my intro data types video: kzbin.info/www/bejne/lWamimCmZbanarc ).. the 0 and 1 are numerical mappings to an outcome. Yes your second assumption is true. The 3 values get mapped to the 3 values you return.. so result would be 0 or 1 from lines 11/15 and user would be user etc
@hichewy6748
@hichewy6748 4 жыл бұрын
@@KylieYYing thanks very much!!
@TIMMMYYYHHH
@TIMMMYYYHHH 4 жыл бұрын
Omg you did this way beter than I did. Thanks for showing me there's a way beter way
@tanzimikramsheikh
@tanzimikramsheikh 3 жыл бұрын
Very realistic rock, paper, scissors program!
@iliya_shorts
@iliya_shorts 4 жыл бұрын
hey I have a problem, it doesn´t matter what I choose I always lose. can you please help me with that?
@mdmahidurrahman6123
@mdmahidurrahman6123 3 жыл бұрын
I got a basic from this video. Thank you so much. Best wishes From Bangladesh.
@1.17animations2
@1.17animations2 3 жыл бұрын
I do not know why, but this code is not working for me, there is a syntax error
@cyberninjarappa
@cyberninjarappa 3 ай бұрын
If Fire and Water are added to this game, 1. Scissors cuts Paper 2. Scissors obstructs Water 3. Paper covers Stone 4. Paper absorbs Water 5. Stone breaks Scissors 6. Stone smothers Fire 7. Fire forges Scissors 8. Fire ignites Paper 9. Water weathers Stone 10. Water douses Fire
@LoLbeautifulsorrowx
@LoLbeautifulsorrowx 3 жыл бұрын
Why do you put (['r','p','s']) in two brackets?
@estebanortega8744
@estebanortega8744 4 жыл бұрын
How did you run the program?
@KylieYYing
@KylieYYing 4 жыл бұрын
I usually run my code in terminal
@janedoe9771
@janedoe9771 4 жыл бұрын
What IDE are you using?
@KylieYYing
@KylieYYing 4 жыл бұрын
Virtual studio code
@sreeragr8906
@sreeragr8906 3 жыл бұрын
how to add score in this?
@danaraujo7870
@danaraujo7870 3 жыл бұрын
hi all. Can anyone help me? I am confused as to how the computer relates the variables in the helper function, (player and opponent) to the ones in the main function (user and computer). By this I mean, when we write, if player == r and opponent == s, how does the computer know which variable, user or computer, corresponds with either variable, player or opponent? Alternatively phrased, it seems as if it is somewhere stated or implied in the code that user = player and computer = opponent; however, I do not see where and am therefore confused with how the helper function knows what I input and what the computer input is. Thanks in advance.
@hunnyujjlani3043
@hunnyujjlani3043 3 жыл бұрын
Hello can u solve me a ques for me plz Write a Python script that accepts two command line parameters, subtracts the smaller number from the larger number, and then outputs the result. Example program output: C:> python subtract.py 13 28 28 - 13 = 15 Hints: • Use an if statement to determine which number is largest.
@faker_fakerplaymaker3614
@faker_fakerplaymaker3614 3 жыл бұрын
thank you. that was very helpful
@ashishthakkar56
@ashishthakkar56 2 жыл бұрын
what platform is this
@hakimchulan
@hakimchulan 4 жыл бұрын
This is awesome to study the design process 👍
@KylieYYing
@KylieYYing 4 жыл бұрын
Thank you!
@mohammadrehan9733
@mohammadrehan9733 3 жыл бұрын
How you can write the codes. How you can run the program?
@miguelmohr1990
@miguelmohr1990 4 жыл бұрын
That’s awesome content here👌🏻
@KylieYYing
@KylieYYing 4 жыл бұрын
Thank you :)
@violentzengaming1347
@violentzengaming1347 4 жыл бұрын
A very very informative vedio!!!!! thanks.
@Ranzy0
@Ranzy0 3 жыл бұрын
Thank you so much so helpful
@gipsydanger897
@gipsydanger897 3 жыл бұрын
every time I run it, when I press enter it just closes the program
@fisherofmen489
@fisherofmen489 3 жыл бұрын
Why is it acceptable to set a function to what it returns??
@Thoko_Love
@Thoko_Love Жыл бұрын
SAME THING HERE dude, its giving me an error everytime I type return
@seetsamolapo5600
@seetsamolapo5600 4 жыл бұрын
Your code is so beautiful Kylie how did you get to this level?
@KylieYYing
@KylieYYing 4 жыл бұрын
Practice!! Also these tutorials are “perfect” coding scenarios where I code the project ahead of time and redo it. This is the reason why tutorials aren’t my favorite type of video. If you want to see the whole thing with bugs and all, follow me on twitch @KylieYing. I’m going to try to do some live stream coding there over break.
@seetsamolapo5600
@seetsamolapo5600 4 жыл бұрын
@@KylieYYing wow superb answer! I'll definitely be following you on twitch. Besides Python, ever considered maybe making mobile app development tutorials for android in Java? Your break down of concepts is awesome.
@KylieYYing
@KylieYYing 4 жыл бұрын
No haha I don’t have any interest in app dev
@khusnulkhotimah454
@khusnulkhotimah454 Жыл бұрын
nice code i like it thx
@fisherofmen489
@fisherofmen489 3 жыл бұрын
Why dont we wanna compare strings? i'm confused
@JamieShortz
@JamieShortz 3 жыл бұрын
Mikasa strikes again! :D
@hola-wm6pz
@hola-wm6pz 3 жыл бұрын
What engine did you use?
@alucardmax4891
@alucardmax4891 3 жыл бұрын
I believe this looks like Visual Studio code
@hola-wm6pz
@hola-wm6pz 3 жыл бұрын
@@alucardmax4891 thank you!
@alucardmax4891
@alucardmax4891 3 жыл бұрын
@@hola-wm6pz no problems, if you see some of her tutorials, she is also using the terminal on the mac but you can do that with windows aswell!
@hola-wm6pz
@hola-wm6pz 3 жыл бұрын
@@alucardmax4891 thank you again
@susntsrstha
@susntsrstha 4 жыл бұрын
How to open the terminal for playing game ?? I'm new
@KylieYYing
@KylieYYing 4 жыл бұрын
Command line/prompt on windows, terminal on mac. Comes on your computer. See my python crash course video if you need more details
@rogancliphub
@rogancliphub 3 жыл бұрын
Thanks so much, helped me with a school assignment :D
@AlokSingh-kg5wq
@AlokSingh-kg5wq 4 жыл бұрын
this was good👌🏻👌🏻
@naesone2653
@naesone2653 3 жыл бұрын
So it might be im a idiot but the code she has in the vid doesnt work for me i had to ad print commands infront of what should be returned because it just ran the game without showing any results basically.... Did i miss something ? also keep in mind i jsut did the basic game where it plays once. still great video helped me shorten my code and learn smth, thanks
@springbootguy
@springbootguy 3 жыл бұрын
give us more like this videos thnks
@OkeminiDavid-b3l
@OkeminiDavid-b3l Күн бұрын
Ma'am tnx a lot but I don't want this to come as a disrespect but I can barely see what your typing I'll really appreciate if u make the font bigger
@niharikaagrawal8962
@niharikaagrawal8962 4 жыл бұрын
awesome video thanks a trillion
@sreeragr8906
@sreeragr8906 3 жыл бұрын
can yo please make a video on flux.........
@arnavpednekar6706
@arnavpednekar6706 4 жыл бұрын
Who is watching this during quarantine
@mutwakilhigzi3686
@mutwakilhigzi3686 3 жыл бұрын
Hi, sorry but what's on line 7
@mutwakilhigzi3686
@mutwakilhigzi3686 3 жыл бұрын
I'm having trouble reading it
@godsowncoders8272
@godsowncoders8272 4 жыл бұрын
Y cubed..😍🔥🔥👩‍💻
@neouia777
@neouia777 3 жыл бұрын
It is very smart way can you pleas make it in Tkinter, thanks
@turtles_btw2935
@turtles_btw2935 3 жыл бұрын
every time i play, i lose the game. Anyone got any help?
@neouia777
@neouia777 3 жыл бұрын
Next time ignore the left sild of the VS and make the font more big pleas
@sharonnnn_
@sharonnnn_ 4 жыл бұрын
Early on in the code it was user and computer. Why did it suddenly change to user and opponent and then back to user and computer?
@KylieYYing
@KylieYYing 4 жыл бұрын
I defined the function using different variable names. As long as you pass in the correct reference into that variable, then it doesn't really matter. I could've even had x and y instead of user and opponent.
@TawhidShaheed
@TawhidShaheed Ай бұрын
************* __Welcome To Rock Paper Scissors Game__************* import random class Rps: def game(self, user_input): options = ["rock", "paper", "scissor"] if user_input not in options: print("Invalid Input") exit() computer_input = random.choice(options) print(f"Computer's option: {computer_input}") if user_input == "rock" and computer_input == "scissor": print("You Won !") elif user_input == "paper" and computer_input == "rock": print("You Won !") elif user_input == "scissor" and computer_input == "paper": print("You Won !") # match tie elif user_input == "paper" and computer_input == "paper": print("Match Tie !") elif user_input == "scissor" and computer_input == "scissor": print("Match Tie !") elif user_input == "rock" and computer_input == "rock": print("Match Tie !") else: print("Computer Won !") while True: user_input = input("pick one option | rock/paper/scissor: ") obj = Rps() obj.game(user_input)
@neo59978
@neo59978 4 жыл бұрын
It keeps telling me that player_wins is not defined and yet it is
@KylieYYing
@KylieYYing 4 жыл бұрын
Have you defined it before you call it? Could you paste your code?
@fisherofmen489
@fisherofmen489 3 жыл бұрын
line 33 doesnt make sense to me
@anti-gamer185
@anti-gamer185 2 жыл бұрын
Hey, very good video but this project could be less complex
@biri1710
@biri1710 4 жыл бұрын
My advice: Maybe you could do Pygame videos :)
@KylieYYing
@KylieYYing 4 жыл бұрын
Maybe! I’ll look into it. Thanks for the suggestion!
@sabihissa622
@sabihissa622 3 жыл бұрын
Wins_necessary = math.ceil(n/2) IndentationErrors: unexpected indent What do I do here?
@parthcodex9466
@parthcodex9466 3 жыл бұрын
import math
@schuylerasplin3744
@schuylerasplin3744 4 жыл бұрын
first time I ever used .5x speed.
@CODEFORTRESS
@CODEFORTRESS 3 жыл бұрын
8:07 That's call rock, paper and scissor not Tic-tac-toe.. 🤣🤣🤣
@laughing-out-loudhd996
@laughing-out-loudhd996 3 жыл бұрын
U graduated!?..
@ngimasinkiyolmo9905
@ngimasinkiyolmo9905 4 жыл бұрын
your code looks so advanced😥.this is the reason i hate looking other code after completing my task.it makes me useless.
@KylieYYing
@KylieYYing 4 жыл бұрын
It took me years to get here! Don’t get discouraged :) Some tips - rather than looking at my code and feeling useless, try to compare yours to mine and understand what I did why I did, and then try to clean yours up based on that! In addition, I’m also making a beginner python series that works from the bottom up. Check it out here: kzbin.info/aero/PLkWv3oO4kHnuKi032yRRYgyQ4kgaNp6gs
@ngimasinkiyolmo9905
@ngimasinkiyolmo9905 4 жыл бұрын
@@KylieYYing already watched it😛
@seetsamolapo5600
@seetsamolapo5600 4 жыл бұрын
Lol tell me about it. Looks so pro, so clean, so succint
@valentina2375
@valentina2375 3 жыл бұрын
thank u
@abdough6549
@abdough6549 2 жыл бұрын
i couldn't understand line 33
@anonymous-xr4xx
@anonymous-xr4xx 4 жыл бұрын
Love from india ❣️
@notcringe2588
@notcringe2588 3 жыл бұрын
10am3 habibyyy
@zainabrimy5212
@zainabrimy5212 3 жыл бұрын
Thank you for all of videos yo do , and you're so cute and good for explication.
@vStarex
@vStarex 3 жыл бұрын
Hi, I know this comment is too late but can u remake this but rock paper scissors with users and bet it like: !rps "@user" "amount credits" Winner gets the money that was bet from the user who started it. Example: Me, !rps "you" 500 I choose rock u choose paper so I win and I get 500 credits from you
@crustysailor8570
@crustysailor8570 3 жыл бұрын
Im here for the copy/paste text. Who has it👀
@KylieYYing
@KylieYYing 3 жыл бұрын
Best command ever
@memeruler6146
@memeruler6146 2 жыл бұрын
Not tic tac toe
@paytonbell2951
@paytonbell2951 4 жыл бұрын
You didn’t teach me anything
@allofscrubs
@allofscrubs 3 жыл бұрын
shes a qt
@ygjt76v0-----
@ygjt76v0----- 3 жыл бұрын
Her boyfriend write this
@dantin1620
@dantin1620 3 жыл бұрын
she sounds so hot
@samziman4222
@samziman4222 4 жыл бұрын
You never made name a veritable
Rock Paper Scissors Game: Python Beginner Project
11:52
NeuralNine
Рет қаралды 6 М.
ССЫЛКА НА ИГРУ В КОММЕНТАХ #shorts
0:36
Паша Осадчий
Рет қаралды 8 МЛН
요즘유행 찍는법
0:34
오마이비키 OMV
Рет қаралды 12 МЛН
-5+3은 뭔가요? 📚 #shorts
0:19
5 분 Tricks
Рет қаралды 13 МЛН
Python for Beginners - Learn Coding with Python in 1 Hour
1:00:06
Programming with Mosh
Рет қаралды 19 МЛН
ROCK PAPER SCISSORS game in Python 🗿
9:29
Bro Code
Рет қаралды 142 М.
5 years of MIT in 20 minutes
21:45
Kylie Ying
Рет қаралды 209 М.
Real-World Coding Interview for Software Engineering (OOP and DP)
1:14:18
8 Rules For Learning to Code in 2025...and should you?
12:59
Travis Media
Рет қаралды 70 М.
Create Rock Paper Scissors in Java in 10 Minutes
10:24
Coding with John
Рет қаралды 122 М.
Minecraft images that are 100% wholesome to end the year.
11:23
Phoenix SC
Рет қаралды 38 М.
5 Useful F-String Tricks In Python
10:02
Indently
Рет қаралды 337 М.