python判断偶数奇数
Here you will get python program to check number is odd or even.
在这里,您将获得python程序以检查数字是奇数还是偶数。
A number is even if it is completely divisible by 2 otherwise it is odd.
即使一个数字可以被2整除,否则它是奇数。
The modulus operator%is used to find remainder of any number. So here we will use it to divide a number by 2 and find the remainder. If remainder is0then number is even otherwise odd.
模数运算符%用于查找任意数量的余数。 因此,在这里我们将使用它来将数字除以2并找到余数。 如果余数为0,则数字为偶数,否则为奇数。
Python程序检查数字是奇数还是偶数 (Python Program to Check Number is Odd or Even)
num = int(input("enter a number: "))if(num%2 == 0):print("number is even")else:print("number is odd")
Output
输出量
enter a number: 11number is odd
输入数字:11个数字为奇数
Comment below if you have any queries related to above python odd even program.
如果您有任何与以上python奇偶程序有关的查询,请在下面评论。
翻译自: //04/python-program-check-number-odd-even.html
python判断偶数奇数
如果觉得《python判断偶数奇数_Python程序检查数字是奇数还是偶数》对你有帮助,请点赞、收藏,并留下你的观点哦!