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. python實(shí)現(xiàn)讀取類別頻數(shù)數(shù)據(jù)畫(huà)水平條形圖案例2. Java 基于UDP協(xié)議實(shí)現(xiàn)消息發(fā)送3. python 如何停止一個(gè)死循環(huán)的線程4. ASP.NET MVC前臺(tái)動(dòng)態(tài)添加文本框并在后臺(tái)使用FormCollection接收值5. php5.6不能擴(kuò)展redis.so的解決方法6. PHP獲取時(shí)間戳等相關(guān)函數(shù)匯總7. 關(guān)于HTML5的img標(biāo)簽8. Python編寫(xiě)nmap掃描工具9. python 爬取嗶哩嗶哩up主信息和投稿視頻10. 如何基于python3和Vue實(shí)現(xiàn)AES數(shù)據(jù)加密
