天天看點

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循環

繼續閱讀