标签:习题 password lse list 控制 大于 min 通过 inpu
l2 = []
for i in range(1,11):
num = input(‘输入第{}个数字‘.format(i))
if num.isdigit():
num = int(num)
l2.append(num)
l2.sort(reverse=True)
print(l2)
flower_num = input(‘输入回答的鲜花的束数:‘)
if flower_num.isdigit():
flower_num = int(flower_num)
if flower_num >9999:
print("小女生直接晕了过去")
elif flower_num >=1000 and flower_num <9999:
print("明天就结婚")
elif flower_num >=100 and flower_num <1000:
print("拉拉手意思意思,有空再约!")
else:
print("你是个好人")
else:
print(‘输入错误,请重新输入鲜花的束数‘)
a = input(‘请输入一个数字‘)
b = input(‘请输入一个数字‘)
c = input(‘请输入一个数字‘)
if a.isdigit() and b.isdigit() and c.isdigit():
a = int(a)
b = int(b)
c = int(c)
if (a > 0 and b > 0 and c > 0) and (a + b > c or a + c > b or b + c > a):
if a == b and a !=c:
print(‘等腰三角形‘)
print(‘周长为:‘,c+a*2)
elif a != b and a !=c and b != c:
print(‘一般三角形‘)
print(‘周长为:‘,a+b+c)
elif a == b and a == c:
print(‘等腰三角形‘)
print(‘周长为:‘,a*3)
else:
print(‘不能构成三角形‘)
else:
print(‘输入的条件有误,请输入大于0的数字‘)
else:
print(‘请输入数字且大于0‘)
方法一:
a = input(‘请输入一个数字‘)
b = input(‘请输入一个数字‘)
c = input(‘请输入一个数字‘)
if a.isdigit() and b.isdigit() and c.isdigit():
a = int(a)
b = int(b)
c = int(c)
if c < b and b < a and c < a:
print(‘c<b<a‘)
elif c < a and a < b and c < b:
print(‘c<a<b‘)
elif b < c and b < a and c < a:
print(‘b<c<a‘)
elif b < a and b < c and a < c:
print(‘b<a<c‘)
elif a < b and a < c and b < c:
print(‘a<b<c‘)
elif a < c and a < b and c < b:
print(‘a<c<b‘)
else:
print(‘输入错误,请重新输入数字‘)
方法二:
a=int(input("请输入一个整数:"))
b=int(input("请输入一个整数:"))
c=int(input("请输入一个整数:"))
dic = {}
dic[a] = "a"
dic[b] = "b"
dic[c] = "c"
lis=list(dic.keys())
lis.sort()
print(dic[lis[2]]+">"+dic[lis[1]]+">"+dic[lis[0]])
方法三:
l1 = []
for i in range(1,4):
a = input(‘请输入第{}个数字‘.format(i))
a = int(a)
l1.append(a)
l1.sort()
print(‘<‘.join(map(str,l1)))
username = input(‘请输入用户名‘)
password = input(‘请输入密码‘)
if username == ‘admin‘ and password == ‘admin‘:
print(‘登录成功‘)
else:
print(‘用户名或密码错误,登录失败‘)
number = input(‘请输入一个数字‘)
if number.isdigit():
number = int(number)
if number % 2 == 0:
print(‘偶数‘)
else:
print(‘奇数‘)
else:
print(‘输入错误,请重新输入‘)
year = input(‘请输入一个数字‘)
if year.isdigit():
year = int(year)
if year % 4 == 0 and year % 100 != 0 or year % 400 == 0 :
print(‘闰年‘)
else:
print(‘不是闰年‘)
else:
print(‘输入错误,请重新输入‘)
number1 = input(‘请输入一个数字‘)
number2 = input(‘请输入一个数字‘)
if number1.isdigit() and number2.isdigit():
number1 = int(number1)
number2 = int(number2)
if number1 <number2:
print(‘最小值是:number1‘)
else:
print(‘最小值是:number2‘)
else:
print(‘输入错误,请重新输入‘)
标签:习题 password lse list 控制 大于 min 通过 inpu
原文地址:https://www.cnblogs.com/puti306/p/12080444.html