Python 7 Levels, L2, Unit 17, Guessing Game I

Powered By EmbedPress

Guessing Game(text):

import random

print("-----Rock Scissor Paper-----")
number = int(input("Please pick: (1.Rock 2.Scissor 3.Paper)"))
rand = random.randint(1, 3)  # random number from computer
person = "User's input"
computer = "Computer's input"
if number == 1:
    person = "Rock"
elif number == 2:
    person = "Scissor"
else:
    person = "Paper"

if rand == 1:
    computer = "Rock"
elif rand == 2:
    computer = "Scissor"
else:
    computer = "Paper"
if number == rand:
    print("Your input is: ", person, "Computer's input is: ", computer, "Tie. =_=")
elif (number == 1 and rand == 2) or (number == 2 and rand == 3) or (number == 3 and rand == 1):
    print("Your input is: ", person, "Computer's input is: ", computer, "You win. ^_^")
else:
    print("Your input is: ", person, "Computer's input is: ", computer, "You lose. ^_^")

Guessing Game(GUI):

import easygui as g
import random as r
g.msgbox("Do you start game?",title = "Guessing Game",image =
         "guess.gif")
rand = r.randint(1,3)#computer's random input
computer = "Computer's input"
if rand == 1:
    computer = "Rock"
elif rand == 2:
    computer = "Scissor"
else:
    computer = "Paper"
person = g.buttonbox(msg="Please input.",title = "Guessing Game",choices = ("Rock","Scissor","Paper"),
                     image = "guess.gif")

if person == computer:
    g.msgbox("You input: "+person+",Computer's input: "+computer+". Tie",title = "Guessing Game",
             image = "h.gif")
elif (rand == 1 and person == "Paper") or (rand == 2 and person == "Rock") or (rand == 3
    and person == "Scissor"):
    g.msgbox("You input: "+person+",Computer's input: "+computer+". You Win!",title = "Guessing Game",
             image = "y.gif")
else:
    g.msgbox("You input: "+person+",Computer's input: "+computer+". You Lose!",title = "Guessing Game",
             image = "s.gif")

dahan1999

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts