answersLogoWhite

0

The best way to do this would be to use the "mod" function. It returns the remainder after performing integer division. For example, 9 mod 2 would be 1 because the remainder of 9/2 is 1. Mod is represented by %. With this in mind, all odd numbers mod 2 will equal 1, and all even numbers will equal 0.

number = raw_input("Please enter an integer: ");

if number % 2 == 1:

print number + " is odd.";

else:

print number + " is even.";

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

Program for check a number is even or odd using PYTHON language?

This program checks whether a number is odd or even. NOTE: This site removes formatting from answers. Replace (tab) with a tab or four spaces. #!/usr/bin/python print("Type a number.") n = input(": ") l = len(n)-1 even = ("02468") if n[l] in even: (tab)print(n, "is even.") if n[l] not in even: (tab)print(n, "is odd.")


How can you tell whether a given number is a multiple of 2?

If it is even


Program to check whether the entered number is even or odd?

#include<stdio.h> #include<conio.h> void main() { int n; printf("ENTER NO FOR CHECK........ "); scanf("%d", &n); if(n%2==0) printf("Given No is EVEN"); else printf("Given No is ODD"); getch(); }


Need a'c' program to find given number is even or odd?

No, thanks.


Do amethystine python eat silvery gibbons?

Even for a python, gibbons are a bit too big.


What is a Python's diet?

Small Python's Diet such as the Ball Python consists of rodents, Medium Python's Diet such as the Carpet Python consists of Chickens, Rodents and even Wallabys, Big Python's Diet such as the Indian Python consists of Rodents, Very Large Python's Diet such as the African Rock Python consists of Thomson's Gazelle, Nyala, Rodents and Nile Crocodiles, Massive Python's Diet such as the Burmese Python consists of Deer, Rodents, Mugger Crocodiles and Storks, Giant Python's Diet such as the Reticulated Python consists of Deer, Stray Dogs and Cats, Wild Pigs, Mugger Crocodiles and even Sun Bears.


How does a PYTHON protect itself from danger?

It depends on the species of python. for example the Python Molurus will attack if threatened and will fight to the death! http://en.wikipedia.org/wiki/Python_molurus The Python Curtis Probably wouldn't defend it self, and because of this they can be used as pets. http://en.wikipedia.org/wiki/Python_curtus But the most common way for a python to defend itself would be to lunge and bite. and even then it usually varies between species on whether it would, continue biting, hold on, or run away after.


Is a California trap door spider stronger than a python?

A spider, even a large spider, is much, much smaller than a python, even a small python. Proportionally to their size, the spider MIGHT be stronger, but a python could easily squish a spider without any trouble.


How do you write a C program to check whether the number is odd or even Ps-using DEV complier?

To write a C program to determine if something is odd or even you need to be a programmer. To write a program in C is complicate and only done by programmers.


Why is the set of even counting numbers well defined?

Because the description which is given is sufficient to decide whether or not any given number is in the set.


Why are numbers odd and even?

That's a more or less arbitrary name given to numbers, to distinguish whether they are divisible by 2 (even) or not (odd).


Is the set of even counting numbers a well defined or not and why?

Yes it is. Given any number you can decide whether or not it belongs to the set.