python基础-02

 1.分苹果

m =7
m_new = 1
while m != 1:
print(m_new,m)
m_new *= m
m -= 1
2.验证码
#随机产生基于范围内的随机数字
#import random
#yzm = random.randrange(1000,9999)
#print(yzm)
import random
for i in range(3):
yanzhengma = random.randrange(1000,9999)
print('验证码为: %d' % yanzhengma)
input_ = int(input('输入你的验证码:'))
if input_ == yanzhengma:
print('ok')
break
else:
print('验证码错误请重新输入')
3.混合密码
import numpy as np
a = ['A','B','1','2']
np.random.randint(a)
print(a)
4.循环
import time
i = 1
while i !=0:
time.sleep(1)
print(i)
i -= 0.1
5. 银行卡密码
import random
yzm = random.randrange(1000,9999)
print('验证码为: %d' % yzm)
input_ =int(input('输入验证码:'))
while input_ = yzm:
print('ok')
break
6.密码输入三次错误锁死
password = int('123456')
passw = int(input('输入你的密码:'))
for i in range(2):

if passw == password:
print('ok')
break
else:
print('密码错误请重新输入')
passw = int(input('输入你的密码:'))
else:
print('账号锁定请移步柜台')
7.计算器
n1,n2 = map(float,input('num1,num2 ').split(','))
choose_method = input('Choose Method:[+,-,*,/]')
if choose_method in '+-*/':
if choose_method =='+':
print('%.2f +%.2f = %.2f' % (n1,n2,n1+n2))
elif choose_method =='-':
print('%.2f - %.2f = %.2f' % (n1,n2,n1-n2))
elif choose_method =='*':
print('%.2f * %.2f = %.2f' % (n1,n2,n1*n2))
else :
print('%.2f / %.2f = %.2f' % (n1,n2,n1/n2))
pass
else:
raise KeyError('only choose [+,-,*,/]')
8.方程组


posted @ 2019-08-04 12:19  Youngstrayschoolgirl  阅读(150)  评论(0编辑  收藏  举报