This article mainly introduces the python applet in detail: scissors, rock, cloth example code, which has certain reference value. Interested friends can refer to it
Nothing to do, Write a small program and practice python, haha:
#!/usr/bin/env python
#coding:utf8
#author : wangganyu188@163.com
#date : 2014-09-11
import random,sys
#Definition of rock-paper-scissors dictionary
dict = {
1:'Scissors',
2:'Stone',
3:'Cloth',
}
for row in dict:
print 'Number:',row, '=',dict[row]
loop = True
while loop:
print 'What did you say? ?'
you = raw_input('Please enter the number and press Enter: If you want to exit the game, press the q key').strip()
if you == 'q':
loop = False
print "Friendly reminder: The game will exit, please play again next time"
sys.exit()
else:
try:
dn = random.randint(1,3)
you = int(you)
if you >= 1 and you
loop = True
print 'You output:',dict[you]
print 'The computer output:',dict[dn]
print 'Result:',
if dn == you:
print 'tie'
elif (you > dn and you - dn == 1) or you + 2 == dn:
print 'You win'
else:
print 'The computer wins'
continue
The above is the detailed content of python applet: scissors, rock, paper example code. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

SublimeText3 Mac version
God-level code editing software (SublimeText3)

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver CS6
Visual web development tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software
