python偶数怎么表达
2024-08-08 08:38:36
在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”。
- 上一篇:一段很现实的话适合发朋友圈
- 下一篇:临时牌照可以上高速吗
猜你喜欢
-
项链便宜不掉色材质
阅读量:57 -
耳钉买什么材质好
阅读量:65 -
保暖内衣买什么材质好
阅读量:25 -
凉席买什么材质好
阅读量:38 -
买棉被买什么材质好
阅读量:75 -
筷子买什么材质好
阅读量:59 -
袜子买什么材质好
阅读量:12 -
菜板买什么材质好
阅读量:66 -
被子买什么材质的最好
阅读量:19 -
茶几买什么材质好
阅读量:47
猜你喜欢
-
阅读量:86
-
阅读量:62
-
阅读量:36
-
阅读量:41
-
阅读量:79
-
阅读量:48
-
阅读量:28
-
阅读量:65
-
阅读量:95
-
阅读量:21