python第二天
1、写作业
第一天学习的作业
#作业1.1
n = 1
while n < 11:
print(n)
if n == 6:
n = n + 2
else:
n = n + 1
#1-100求奇数
n = 1
while n < 101:
temp = n % 2
if temp == 0:
pass
else:
print(n)
n = n + 1
#1-100求偶数
n = 1
while n < 101:
temp = n % 2
if temp == 1:
pass
else:
print(n)
n = n + 1
#1-100求和
n = 1
m = 1
while m < 101:
n = n + m
m = m + 1
print(n-1)
#作业1.5
#登录三次报错
s = "123" #正确密码
n = 1 #循环次数
while n < 4:
n = n + 1
mn = input("请输入密码")
if mn == s :
print("密码正确")
exit("进入")
else:
print("密码错误")
print("密码次数超限")
注:作业中input函数是向程序输入字符串函数,而不是数字,所以如果为数字密码需要转换为字符串格式,否则会报错

浙公网安备 33010602011771号