小游戏:剪刀石头布


 

#! /usr/bin/env python
# -*- coding:utf-8 -*-
import random
while True:
    player = int(input("\n请输入你猜的\"石头-1、剪刀-2、布-3\":\n"))

    computer = int(random.randint(1,3))
    if computer == 1:
        print("电脑出:石头-%d" % computer)
    elif computer == 2:
        print("电脑出:剪刀-%d" % computer)
    else:
        print("电脑出:布-%d" % computer)

    if (player == 1 and computer == 2) or (player == 2 and computer == 3) or (player == 3 and computer == 1):
        print("玩家赢")
    elif computer == player:
        print("平局")
    else:
        print("电脑赢")

 

智能推荐

注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
© 2014-2019 ITdaan.com 粤ICP备14056181号  

赞助商广告