Welcome, guest | Sign In | My Account | Store | Cart

A simple game :)

Python, 33 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python
# -*-coding:utf-8-*-
import time
from time import sleep
import random

sus="-"*35
depo=["rock","paper","scissors"]
while True:
    x=input("rock , paper, scissors: ")
    if x not in depo:
        print ("Dont cheat!")
        continue

    pc=random.choice(depo)
    sleep(0.5)
    print (("Computer picked {}.").format(pc))
    if x==pc:
        sleep(0.5)
        print (("\nIt's a draw.\n{}").format(sus))
    elif x=="rock" and pc=="scissors":
        sleep(0.5)
        print (("\nYou win.rock beats scissors\n{}").format(sus))
    elif x=="paper" and pc=="rock":
        sleep(0.5)
        print (("\nYou win.paper beats rock\n{}").format(sus))
    elif x=="scissors" and pc=="paper":
        sleep(0.5)
        print (("\nYou win.scissors beats paper\n{}").format(sus))
    else:
        sleep(0.5)
        print (("\nYou lose. {} beats {}\n{}").format(pc,x,sus))
input()

1 comment

Grant Jenks 6 years, 9 months ago  # | flag

Great idea for a simple text-based game! I have developed a number of games for education in Free Python Games at http://www.grantjenks.com/docs/freegames/ Would you consider contributing your game?