tedu训练营day04

1.猜拳:
import random
list = ['石头','剪刀','布']
y = input('''
(0) 石头
(1) 剪刀
(2) 布
请出拳(0/1/2):
*******************''')
computer = random.choice(list)
you = list[int(y)]
win_list = [['石头','剪刀'],['剪刀','布'],['布','石头']]
if [you,computer] in win_list:
print('你出拳:%s,电脑出拳:%s,你赢了!' % (you,computer))
elif you == computer:
print('平局!!!')
else:
print('你出拳:%s,电脑出拳:%s,你输了!' % (you,computer)) 2.随机n位密码
import random
import string
result = ''
i = 1
n = int(input('随机生成几位密码:'))
char = string.ascii_letters + string.digits + '_'
while i<=n:
a = random.choice(char)
result += a
i += 1
print(result)
上一篇:HDU 5171 GTY's birthday gift 矩阵快速幂


下一篇:vim快速指南