为下列代码增加循环效果 import random # # 计算电脑出拳的随机数字 # computer=random.randint(0,2) # # print(computer) # player =int(input('请出拳:0-石头,1-剪刀,2-布:')) # #玩家胜利 p0:c1或p1:c2或p2:cO # if((player ==0)and(computer ==1))or((player == 1)and(computer==2))or((player ==2)and(computer == 0)): # print(f"电脑出的为:{computer}") # print('玩家获胜') # # 平局:玩家 == 电脑 # elif player == computer: # print(f"电脑出的为:{computer}") # print('平局') # else: # print(f"电脑出的为:{computer}") # print('电脑获胜')
理解问题为下列代码增加循环效果 import random # # 计算电脑出拳的随机数字 # computer=random.randint(0,2) # # print(computer) # player =int(input('请出拳:0-石头,1-剪刀,2-布:')) # #玩家胜利 p0:c1或p1:c2或p2:cO # if((player ==0)and(computer ==1))or((player == 1)and(computer==2))or((player ==2)and(computer == 0)): # print(f"电脑出的为:{computer}") # print('玩家获胜') # # 平局:玩家 == 电脑 # elif player == computer: # print(f"电脑出的为:{computer}") # print('平局') # else: # print(f"电脑出的为:{computer}") # print('电脑获胜')
已完成理解「为下列代码增加循环效果 import random # # 计算电脑出拳的随机数字 # computer=random.randint(0,2) # # print(computer) # player =int(input('请出拳:0-石头,1-剪刀,2-布:')) # #玩家胜利 p0:c1或p1:c2或p2:cO # if((player ==0)and(computer ==1))or((player == 1)and(computer==2))or((player ==2)and(computer == 0)): # print(f"电脑出的为:{computer}") # print('玩家获胜') # # 平局:玩家 == 电脑 # elif player == computer: # print(f"电脑出的为:{computer}") # print('平局') # else: # print(f"电脑出的为:{computer}") # print('电脑获胜')」
展开阅读网页