猜拳游戏and用户登录

时间:2019-10-10 20:21:24   收藏:0   阅读:91
猜拳游戏
win=0
lost=0
ping=0
while True:
print(‘胜:%s 输:%s 平:%s‘% (win,lost,ping))
print(‘欢迎来猜拳\n1.拳头 2.剪刀 3.布 4.退出‘)
import random
chooses = [‘石头‘,‘剪刀‘,‘布‘]
dn = random.choice(chooses)
ren = input(‘请出拳:‘)
if (ren == ‘1‘ and dn ==‘石头‘) or (ren == ‘2‘ and dn == ‘剪刀‘) or (ren==‘3‘ and dn ==‘布‘):
ping += 1
print(‘平局‘)
elif (ren == ‘1‘ and dn == ‘剪刀‘) or (ren == ‘2‘ and dn == ‘布‘) or (ren == ‘3‘ and dn == ‘石头‘):
win += 1
print(‘赢啦‘)
elif (ren == ‘1‘ and dn == ‘布‘) or (ren == ‘2‘ and dn == ‘石头‘) or (ren == ‘3‘ and dn == ‘剪刀‘):
lost += 1
print(‘输啦‘)
elif (ren == ‘4‘):
break
elif not ren:
continue
   else:
  print(‘输入错误‘)
   print(‘\033[31m=\033[0m‘ * 30)
用户登录
username = ‘root‘
password = ‘root‘
count = 0
print(‘请登录...‘)
while True:
user = input(‘username:‘)
pwd = input(‘password:‘)
if user == username and pwd == password:
print(‘欢迎登陆‘)
break
else:
count += 1
print(‘密码错误‘, count)
if count == 3:
print(‘滚‘)
break
 

 

 
评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!