python 02 if

 if的格式

>>> 1<3     

True        真
>>> 1>3
False        假

if   条件:                      条件 + :   

(tab)执行语句

(tab)执行语句            前置tab为if条件下执行trun(真)

.....

else:

(tab) 执行语句      执行false(假)

.......

判断输入数字是否为8

1 print('hi')
2 temp= input (" number?")
3 guess=int(temp)
4 if guess==8:
5     print("yes")
6 else:
7     print("on")
8 print("88")
9     

猜你喜欢

转载自www.cnblogs.com/17s4029/p/9462776.html