Question

python Ask the user for a number. Depending on whether the number is even or odd,...

python Ask the user for a number. Depending on whether the number is even or odd, print out an appropriate message to the user. (tip: Pick positive numbers, use a variable named mod= num % 2, if mod ==0 ---> even number) If the number is odd, print out the number integer divided by 2 and if the number is even print out the number divided by 2.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
num = int(input("Enter a number: "))
mod = num % 2
if(mod==0):
    print(num/2)
else:
    print(num//2)

Add a comment
Know the answer?
Add Answer to:
python Ask the user for a number. Depending on whether the number is even or odd,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT