Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import*
- import tkinter.simpledialog
- import tkinter.messagebox
- import random
- root = Tk()
- w = Label(root, text="Rock Paper Scissors")
- w.pack()
- ROCK = 0
- PAPER = 1
- SCISSORS = 2
- computer = random.randint(0,2)
- user = tkinter.simpledialog.askinteger("Choose wisely", "Enter 0 for ROCK, 1 for PAPER, or 2 for SCISSORS.")
- # 1. this code will tell if the computer throws ROCK. add code to tell
- # you when the computer throws SCISSORS and PAPER. It will be very similar.
- if computer == ROCK:
- tkinter.messagebox.showinfo("Computer", "The computer throws ROCK")
- # 2. this is the code to determine who wins if the user picks ROCK. Write the
- # code below it to handle if the user has PAPER and if the user has SCISSORS.
- # the code will look very similar.
- if user == ROCK:
- if computer == PAPER:
- tkinter.messagebox.showinfo("Rock vs Paper", "You lose, PAPER covers ROCK!")
- elif computer == ROCK:
- tkinter.messagebox.showinfo("Rock vs Rock", "It's a tie, we both have ROCK!")
- else: #computer == SCISSORS
- tkinter.messagebox.showinfo("Rock vs SCISSORS", "You win, ROCK breaks SCISSORS!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement