RESOURCES:
I haven't posted in a bit, so I've added resources from the last 2 weeks:
Week 8 Slides: https://docs.google.com/presentation/d/1eul03VByEhgR7TDKSvk373H5dxwkN_gDroNlLmq_YOI/edit?usp=sharing
Week 9 Slides:
https://docs.google.com/presentation/d/1sjEbay9nKKXypizMsMhUlKzzG4M9fnVBbPuC5V5gM2k/edit?usp=sharing
Week 10 Slides:
https://docs.google.com/presentation/d/1tyDKdw8DQenLrrty3HjntSAm-okXjBDbWo6rWHFGVmc/edit?usp=sharing
Example code:
Week 8: https://replit.com/@ShravyaS/IntroToPython-8
Week 9: https://replit.com/@ShravyaS/IntroToPython-9
Week 10: https://replit.com/@ShravyaS/IntroToPython-10
MINI PROJECT:
For this project, please create a program that plays rock paper scissors with the user. The program should keep prompting the user for their move and keep playing games of rock paper scissors until the user enters "stop". Once "stop" is entered, print out the total number of wins and the total number of losses and the total number of draws.
- Use the random module, while loop, use input/print, and use if statements
Sample output: https://asciinema.org/a/AgNJ6i68mN3KkEvEvYU06Cc87
import random print("Let's play rock, paper, scissors!"); print('Please choose 0 for rock, 1 for paper, 2 for scissors, and type STOP to end'); user_input = input(); draw = 0; lose = 0; win = 0; while (user_input != "STOP"): user_input = int(user_input); my_choice = random.randrange(0,2,1); if (user_input == my_choice): print(f"my choice is also {my_choice}"); print("It's a draw"); draw = draw + 1; elif (user_input == 0): print(f"my choice is {my_choice}"); if (my_choice == 1): print("You lose"); lose = lose + 1; else: print("You win"); win = win + 1; elif (user_input == 1): print(f"my choice is {my_choice}"); if (my_choice == 2): print("You lose"); lose = lose + 1; else: print("You win"); win = win + 1; elif (user_input == 2): print(f"my choice is {my_choice}"); if (my_choice == 0): print("You lose"); lose = lose + 1; else: print("You win"); win = win + 1; else: print("invalid comparison"); print(f"my choice is {my_choice}"); print(f"user input is {user_input}"); print("\nContinue next round"); user_input = input(); total = win + draw + lose; print(f"You have played {total} games in total"); print(f"You win {win} times"); print(f"You lose {lose} times"); print(f"You draw {draw} times");