>>> x,y,z=6,5,4
>>> if x<y and x<z:"x"
elif y<x and y<z:"y"
else:"z"
'z'
【小甲鱼的↓↓】
>>> small = x if (x < y and x < z) else (y if y < z else z)
z
1. i = 0
2. string = 'ILoveFishC.com'
3. while i < len(string)):
4. print(i)
5. i += 1
>>>
0
1
2
3
4
5
6
7
![小甲鱼的意思是→ →](https://img-blog.csdnimg.cn/20200528114104130.jpg#pic_right)
【1 这样成了列表模式了】
a="love you"
print(list(range(len(a))))
[0, 1, 2, 3, 4, 5, 6, 7]
password="liucd"
count=3
temp=input("请输入你的密码:")
while count>0:
if temp==password:
print("yes,进入程序……")
break
elif "*" in password:print("no ,not"*"")
else:
count-=1
if count!=0:
print("no,你还有",count,"次机会。")
temp=input("请重新输入你的密码:")
else:
print("sorry,你没有机会了")
>>>
= RESTART: C:/Users/Administrator/AppData/Local/Programs/Python/Python38-32/00.py
请输入你的密码:3
no,你还有 2 次机会。
请重新输入你的密码:d
no,你还有 1 次机会。
请重新输入你的密码:liucd
yes
for i in range(100,999):
if i==(i//100)**3+((i-(i//100)*100)//10)**3+((i-(i//100)*100-(i-(i//100)*100)//10*10)/1)**3:
print(i)
>>>
= RESTART: C:/Users/Administrator/AppData/Local/Programs/Python/Python38-32/00.py
153
370
371
407
【条理些】
for i in range(100,999):
a=i//100
b=(i-a*100)//10
c=(i-a*100-b*10)
if i==a**3+b**3+c**3:
print(i)
【小甲鱼 ↓ ↓】
for i in range(100,999):
sum=0
temp=i
while temp:
sum=sum+(temp%10)**3
temp=temp//10
if sum==i:
print(i)
print("红色\t黄色\t绿色\t")
for r in range(4):
for y in range(4):
for g in range(2,7):
if r+y+g==8:
print(r,"\t",y,"\t",g)
>>>
= RESTART: C:/Users/Administrator/AppData/Local/Programs/Python/Python38-32/00.py
红色 黄色 绿色
0 2 6
0 3 5
1 1 6
1 2 5
1 3 4
2 0 6
2 1 5
2 2 4
2 3 3