- if 语句
- elif:判断真后不再继续做后续判断,多次判断会一直判断到真
if val == 0:
return 0
elif val<0:
return -1
else:
return 1
- for 循环
#1-10偶数和Sum = 0for i in range(1,10): if i%2 =0: Sum+=i
- while 循环
i = 1
while i<100:
i += 1
print(i)
if val == 0:
return 0
elif val<0:
return -1
else:
return 1
#1-10偶数和Sum = 0for i in range(1,10): if i%2 =0: Sum+=i
i = 1
while i<100:
i += 1
print(i)