python偶數(shù)怎么表達(dá) python判斷偶數(shù)奇數(shù)
在python編譯器中,新建一個空白的PYTHON文檔;輸入:
n = float(input('Please input a number: '))
if n % 2 == 0:
print('This is an even')
elif n % 2 != 0:
print('This is an odd')
如果輸入的數(shù)字是偶數(shù),輸出的文字為“This is an even”。如果輸入的數(shù)字是奇數(shù),輸出的文字為“This is an odd”。
python怎么判斷奇數(shù)偶數(shù)
1、首先打開JUPYTER NOTEBOOK,新建一個空白的PYTHON文檔。也可以用其它編譯器的。
2、輸入以下內(nèi)容:
num1 = int(input('Please input a number: '))
num2 = int(input('Please input a number: '))
if num1 % num2 == 0:
print('This is OK.')
elif num1 % num2 != 0:
print('This is NOT OK')
如果輸入的數(shù)字為偶數(shù),文檔就會返回文字'This is OK”;如果輸入的數(shù)字是奇數(shù),文檔就會返回文字'This is NOT OK”。
相關(guān)文章:
1. .NET中l(wèi)ambda表達(dá)式合并問題及解決方法2. JSP數(shù)據(jù)交互實(shí)現(xiàn)過程解析3. 淺談python出錯時traceback的解讀4. 利用promise及參數(shù)解構(gòu)封裝ajax請求的方法5. Python importlib動態(tài)導(dǎo)入模塊實(shí)現(xiàn)代碼6. python matplotlib:plt.scatter() 大小和顏色參數(shù)詳解7. windows服務(wù)器使用IIS時thinkphp搜索中文無效問題8. ASP 信息提示函數(shù)并作返回或者轉(zhuǎn)向9. 在Android中使用WebSocket實(shí)現(xiàn)消息通信的方法詳解10. Nginx+php配置文件及原理解析
