Python 判断奇数偶数
Python 3 教程
· 2019-02-12 10:42:28
以下实例用于判断一个数字是否为奇数或偶数:
实例(Python 3.0+)
# Filename : test.py
# author by : www.codercto.com
# Python 判断奇数偶数
# 如果是偶数除于 2 余数为 0
# 如果余数为 1 则为奇数
num = int(input("输入一个数字: "))
if (num % 2) == 0:
print("{0} 是偶数".format(num))
else:
print("{0} 是奇数".format(num))
我们也可以使用内嵌 if 语句来实现:
执行以上代码输出结果为:
输入一个数字: 3 3 是奇数
点击查看所有 Python 3 教程 文章: https://www.codercto.com/courses/l/10.html
Building Web Reputation Systems
Randy Farmer、Bryce Glass / Yahoo Press / 2010 / GBP 31.99
What do Amazon's product reviews, eBay's feedback score system, Slashdot's Karma System, and Xbox Live's Achievements have in common? They're all examples of successful reputation systems that enable ......一起来看看 《Building Web Reputation Systems》 这本书的介绍吧!