判断语句

if

1
2
if love == 100:
print("I love you!")

if else

1
2
3
4
if love == 100:
print("I love you very much!")
else:
print("Maybe?")

if elif else

1
2
3
4
5
6
if love == 100:
print("I love you so much!")
elif 0<love<100:
print("Maybe?")
else:
print("No!")

循环

while循环

1
2
3
4
i = 0
while i < 100:
print("美羊羊,我喜欢你")
i += 1

for循环

1
2
for i in range(1, 100):
print("美羊羊,我喜欢你")

range的三种使用方式
range(num)
range(num1,num2)
range(num1,num2,step)

continue和break

continue: 跳过当前循环
break: 跳出循环