电脑随机出拳

 1 import random
 2 player = int(input("请输入您要出的拳:石头(1)/剪刀(2)/布(3):"))
 3 computer = random.randint(1, 3)
 4 print("玩家选择的是%d-电脑选择的是%d" % (player, computer))
 5 if (player == 1 and computer == 2) or (player == 2 and computer == 3) or (
 6         player == 3 and computer == 1):
 7     print("电脑弱爆了!")
 8 elif computer == player:
 9     print("心有灵犀!")
10 else:
11     print("电脑太厉害了!")

 

上一篇:Java单体应用 - 架构模式 - 03.设计模式-25.访问者模式


下一篇:Google Computer Engine入门