1. 程式人生 > >python基礎第七天

python基礎第七天

tty 七天 python image 結果 odin .cn python基礎 src

#!/usr/bin/python
# -*- coding: UTF-8 -*-

# 例3:if語句多個條件

num = 9
if num >= 0 and num <= 10:    # 判斷值是否在0~10之間
    print ‘hello‘
>>> hello		# 輸出結果

num = 10
if num < 0 or num > 10:    # 判斷值是否在小於0或大於10
    print ‘hello‘
else:
	print ‘undefine‘
>>> undefine		# 輸出結果

num = 8
# 判斷值是否在0~5或者10~15之間
if (num >= 0 and num <= 5) or (num >= 10 and num <= 15):    
    print ‘hello‘
else:
    print ‘undefine‘
>>> undefine		# 輸出結果
**************************************
實例演示
**************************************

技術分享

python基礎第七天