python偶數(shù)怎么表達(dá) python判斷偶數(shù)奇數(shù)
在python編譯器中,新建一個(gè)空白的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、首先打開(kāi)JUPYTER NOTEBOOK,新建一個(gè)空白的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ù),文檔就會(huì)返回文字'This is OK”;如果輸入的數(shù)字是奇數(shù),文檔就會(huì)返回文字'This is NOT OK”。
相關(guān)文章:
1. IntelliJ IDEA導(dǎo)入jar包的方法2. docker鏡像完全卸載的操作步驟3. IntelliJ IDEA配置Tomcat服務(wù)器的方法4. idea刪除項(xiàng)目的操作方法5. 使用Maven 搭建 Spring MVC 本地部署Tomcat的詳細(xì)教程6. IntelliJ IDEA調(diào)整字體大小的方法7. idea打開(kāi)多個(gè)窗口的操作方法8. idea導(dǎo)入maven項(xiàng)目的方法9. IntelliJ IDEA設(shè)置自動(dòng)提示功能快捷鍵的方法10. IntelliJ IDEA安裝插件的方法步驟

網(wǎng)公網(wǎng)安備