岩石,纸,剪刀在python提示,使其更好

时间:2013-11-29 13:35:56

标签: python

我最近刚刚学会了一些Python,我为Rock,paper,剪刀编写了一个脚本。 我只想要任何提示,以使其更好,以及如何在未来更好。 我听了一些提示并添加了分数计数器并修复了一些东西。 我做得对吗? 脚本是:

import random
import time
print('Welcome to Rock, Paper, Scissors')
print(' '*25) 
wins = 0
loses = 0
draws = 0
point= int(input('How many rounds do you want to play?'))
list = ['r','p','s']
for x in range (1,(point+1)):
    computer = random.choice(list)
    human=str(input('Choose (R)ock, (P)aper, or (S)cissors?'))
    if human == computer:
        draws = draws + 1
        print('''Human: {}         Computer: {}           A draw
        Wins = {}   Loses = {}   Draws = {}'''.format(human,computer,wins,loses,draws))
        print(' '*25)
    elif human == 'r' and computer == 'p':
        loses = loses + 1
        print('''Human: ROCK       Computer: PAPER        Computer wins
        Wins = {}   Loses = {}   Draws = {}'''.format(wins,loses,draws))
        print(' '*25)
    elif human == 'r' and computer == 's':
        wins = wins + 1
        print('''Human: ROCK       Computer: SCISSORS     Human wins
        Wins = {}   Loses = {}   Draws = {}'''.format(wins,loses,draws))
        print(' '*25)
    elif human == 'p' and computer == 's':
        loses = loses + 1
        print('''Human: PAPER      Computer: SCISSORS     Computer wins 
        Wins = {}   Loses = {}   Draws = {}'''.format(wins,loses,draws))
        print(' '*25)
    elif human == 'p' and computer == 'r':
        wins = wins + 1
        print('''Human: PAPER      Computer: ROCK        Human wins
        Wins = {}   Loses = {}   Draws = {}'''.format(wins,loses,draws))
        print(' '*25)
    elif human == 's' and computer == 'p':
        wins = wins + 1
        print('''Human: SCISSORS   Computer: PAPER    Human wins
        Wins = {}   Loses = {}   Draws = {}'''.format(wins,loses,draws))
        print(' '*25)
    elif human == 's' and computer == 'r':
        loses = loses + 1
        print('''Human: SCISSORS   Computer: ROCK     Computer wins
        Wins = {}   Loses = {}   Draws = {}'''.format(wins,loses,draws))
        print(' '*25)
    else:
        print('Error')

0 个答案:

没有答案