Python 7 Levels, L2, Unit 18, Guessing Game II

Powered By EmbedPress

Exercise:

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