Python: Check whether a given number is Oddish or Evenish
Python Basic - 1: Exercise-107 with Solution
Write a Python program to check whether a given number is odd or even.
A number is called "Oddish" if the sum of all of its digits is odd, and a number is called "Evenish" if the sum of all of its digits is even.
Sample Solution:
Python Code:
def oddish_evenish_num(n):
return 'Oddish' if sum(map(int, str(n))) % 2 else 'Evenish'
n = 120
print("Original Number",n)
print("Check whether the sum of all digits of the said number is odd or even!")
print(oddish_evenish_num(120))
n = 321
print("Original Number",n)
print("Check whether the sum of all digits of the said number is odd or even!")
print(oddish_evenish_num(321))
n = 43
print("Original Number",n)
print("Check whether the sum of all digits of the said number is odd or even!")
print(oddish_evenish_num(43))
n = 4433
print("Original Number",n)
print("Check whether the sum of all digits of the said number is odd or even!")
print(oddish_evenish_num(4433))
n = 373
print("Original Number",n)
print("Check whether the sum of all digits of the said number is odd or even!")
print(oddish_evenish_num(373))
Sample Output:
Original Number 120 Check whether the sum of all digits of the said number is odd or even! Oddish Original Number 321 Check whether the sum of all digits of the said number is odd or even! Evenish Original Number 43 Check whether the sum of all digits of the said number is odd or even! Oddish Original Number 4433 Check whether the sum of all digits of the said number is odd or even! Evenish Original Number 373 Check whether the sum of all digits of the said number is odd or even! Oddish
Pictorial Presentation:
Flowchart:

Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a Python program to test whether a given integer is Pandigital number or not.
Next: Write a Python program that takes three integers and check whether the sum of the last digit of first number and the last digit of second number equal to the last digit of third number.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join