文章詳情頁
python偶數怎么表達 python判斷偶數奇數
瀏覽:102日期:2022-08-08 11:53:29
在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')
如果輸入的數字是偶數,輸出的文字為“This is an even”。如果輸入的數字是奇數,輸出的文字為“This is an odd”。
python怎么判斷奇數偶數
1、首先打開JUPYTER NOTEBOOK,新建一個空白的PYTHON文檔。也可以用其它編譯器的。
2、輸入以下內容:
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')
如果輸入的數字為偶數,文檔就會返回文字'This is OK”;如果輸入的數字是奇數,文檔就會返回文字'This is NOT OK”。
相關文章:
1. React+umi+typeScript創建項目的過程2. ASP調用WebService轉化成JSON數據,附json.min.asp3. php測試程序運行速度和頁面執行速度的代碼4. php網絡安全中命令執行漏洞的產生及本質探究5. ASP.NET Core 5.0中的Host.CreateDefaultBuilder執行過程解析6. 無線標記語言(WML)基礎之WMLScript 基礎第1/2頁7. Warning: require(): open_basedir restriction in effect,目錄配置open_basedir報錯問題分析8. ASP中常用的22個FSO文件操作函數整理9. SharePoint Server 2019新特性介紹10. 三個不常見的 HTML5 實用新特性簡介
排行榜
