1.代码明细.
# 如何写python程序判断奇数偶数
x = int(input("请输入数字:"))
if x % 2 == 0:
print("偶数")
else:
print("奇数")
if x % 2 != 0:
print("奇数")
else:
print("偶数")
if not (x % 2 == 1):
print("偶数")
else:
print("奇数")
2.操作明细.
tarena@tedu:~/桌面$ python3 not.py
请输入数字:75
奇数
奇数
奇数
tarena@tedu:~/桌面$ python3 not.py
请输入数字:99
奇数
奇数
奇数
3.代码说明.
案例中,给出了三种判断奇数,偶数的三种方法.
4.others.
我现在只能先模仿学习,日后,熟练了,在自己编写代码.
tarena zhuhairui 2018.7.7 21:01 xinfangcun

网友评论