2.5k views
0 votes
Create a Python code that will accept the user's input of a number. If the number is even, return the response That is an even number. If the number is odd, return the response That is an odd number. If the number is divisible by 5, return the message Your number is divisible by 5. If the number is divisible by 10, return the message Your number is even, divisible by 5, and is a factor of 10.

User Saptarsi
by
7.8k points

1 Answer

6 votes

Final answer:

To create a Python code that accepts a user's input of a number and determines its characteristics, use if-else statements and modulo division.

Step-by-step explanation:

To create a Python code that accepts a user's input of a number and returns different responses based on the characteristics of the number, you can use a combination of if-else statements and modulo division.

Here's an example:

num = int(input('Enter a number: '))

if num % 2 == 0:
if num % 10 == 0:
print('Your number is even, divisible by 5, and is a factor of 10.')
else:
print('That is an even number.')
elif num % 5 == 0:
print('Your number is divisible by 5.')
else:
print('That is an odd number.')

User Muffinista
by
7.1k points