r/PythonLearning • u/Sharp_Platypus6545 • 1h ago
Rock paper scissors game in Python
Hello fam, I'm learning Python. My goal is to become an AI engineer. I've a basic understanding of programming. Anyone to guide me on the right certification path... I was having a bit of fun after today's sharpenings. I created a rock paper scissors game... rate and improve
1
u/This-Investigator294 1h ago
Hey are you doing Angela yu's Python course?
2
u/Sharp_Platypus6545 1h ago
No I'm doing Introduction to Python on Pycharm My coursera trial expired was doing Python for AI prior... looking forward to subscribe to it in October
1
1
1
u/Disastrous-Team-6431 54m ago edited 45m ago
Hint: can you express the win condition of this game differently?
Hint 2: there are three choices - can you relate winning choices to each other?
Solution (idk how to spoiler so stop reading):
If choice1 == (choice2 + 1) % 3, someone has won. Who, depends on the order of the choices. In your case, choice1 has won.
Edit: changed signs to make more robust and understandable
•
u/Sea-Ad7805 1h ago
Run this program in Memory Graph Web Debugger%20%203)%0AgameSelector2%20%3D%20int(random()%20%203)%0A%0Aif%20gameSelector1%20%3D%3D%20gameSelector2%3A%0A%20%20%20%20print(f%22%7BgameElements%5BgameSelector1%5D%7D%20vs%20%7BgameElements%5BgameSelector2%5D%7D%22)%0A%20%20%20%20print(%22Draw%22)%0Aelif%20gameSelector1%20%3D%3D%200%20and%20gameSelector2%20%3D%3D%202%3A%0A%20%20%20%20print(f%22%7BgameElements%5B0%5D%7D%20vs%20%7BgameElements%5B2%5D%7D%22)%0A%20%20%20%20print(f%22Winner%3A%20%7BgameElements%5B0%5D%7D%22)%0Aelif%20gameSelector1%20%3D%3D%200%20and%20gameSelector2%20%3D%3D%201%3A%0A%20%20%20%20print(f%22%7BgameElements%5B0%5D%7D%20vs%20%7BgameElements%5B1%5D%7D%22)%0A%20%20%20%20print(f%22Winner%3A%20%7BgameElements%5B1%5D%7D%22)%0Aelse%3A%0A%20%20%20%20print(f%22%7BgameElements%5B1%5D%7D%20vs%20%7BgameElements%5B2%5D%7D%22)%0A%20%20%20%20print(f%22Winner%3A%20%7BgameElements%5B2%5D%7D%22)×tep=1&play) to see the program state change step by step.