天天看点

5.2 if,while语句

5.2.1 if 语句格式:

if 判断条件:

   执行语句······

elif 判断条件:

else:

例如:

a=input('Please input a num: ')

b=0

if int(a)>b:

   print('a是正数')

elif int(a)==0:

   print('a等于0')

else:

   print('a是负数')

5.2.2 while语句格式:

while 判断条件:

while 1:

   print('111111')

   break

上一篇: 5.3 for循环

继续阅读