python偶数怎么表达 python判断偶数奇数

elif n % 2 != 0:print("This is an odd")如果输入的数字是偶数,输出的文字为“This is an even”。如果输入的数字是奇数,输出的文字为“This is an odd”。python怎么判断奇数偶数 1、首先打开JUPYTER NOTEBOOK,新建一个空白的PYTHON文档。也可以用其它编译器的。2、输入以下内容:num1 = ...
python偶数怎么表达 python判断偶数奇数
在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”。
2024-03-31
mengvlog 阅读 7 次 更新于 2025-07-19 02:10:11 我来答关注问题0
檬味博客在线解答立即免费咨询

Python相关话题

Copyright © 2023 WWW.MENGVLOG.COM - 檬味博客
返回顶部