一,随机输入三个数,并判断最大值
print("这是一个比肩参数最大值的小程序")
number1 = input('请输入参数1:')
number2 = input('请输入参数2: ')
number3 = input('请输入参数3: ')
max_num = 0
if number1 > number2:
max_num = number1
if max_num > number3:
print('最大的数是:'+ max_num)
else:
print('最大的数是:'+ number3)
else:
max_num = number2
if max_num > number3:
print('最大的数是:' + max_num)
else:
print('最大的数是:' + number3)
二,模拟一个帐号登陆程序,错误三次无法登陆并退出程序
A = 1
#初始化密码
password = '123456'
S = True
#开始循环
while S:
mima = input("请输入密码: ")
#密码正确,跳出循环
if password == mima:
print("密码正确,欢迎登陆")
S = False
#循环3次,终止程序
elif A == 3:
print("错误次数达到3次,中断登陆")
break
#密码错误,继续循环
else:
print("密码错误,请重新输入")
A = A+1
else:
print("欢迎登陆")
1 user = 'CatdeXin'
2 passwd = 'abc123'
3
4 counter = 0
5 while counter < 3:
6 username = input('username: ')
7 password = input('password: ')
8
9 if username == user and password == passwd:
10 print("welcome %s login..."% user)
11 passwd_authentication = True
12 break
13 else:
14 print("Invalid username or password !")
15
16 counter += 1
17 if counter == 3:
18 keep_going_choice = str.title(input("Do you try to start again?【Y/N】"))
19 if keep_going_choice == 'Y':
20 counter = 0
21
22 else: print("Invalid username or password !")
三,输入99乘法表
x = 1
while y < 10:
#print(str(x)+'*'+str(x)+'=',x*x)
y = 1
while y <= x:
print(y,'*',x,'=',y*x,end="\t")
y += 1
print()
x+=1