Answer to Question #299813 in Python for Dhea M. Maddela

Question #299813

Create a Python script that will accept three integers and will check each input number. If the input number is EVEN it will display the square cube of the number and if the number is ODD, it will display the square of the number.


Sample Output:

Number 1: 5

Number 2: 8

Number 3: 3

The square of 5 is 25

The cube of 8 is 512

The square of 3 is 9


I need the code to have an output stated above.


1
Expert's answer
2022-02-19T07:19:03-0500
print('Number 1: ', end='')
number1 = int(input())
print('Number 2: ', end='')
number2 = int(input())
print('Number 3: ', end='')
number3 = int(input())
if number1 % 2 == 0:
   print(f'The cube of {number1} is {number1 ** 3}')
else:
   print(f'The square of {number1} is {number1 ** 2}')
if number2 % 2 == 0:      
   print(f'The cube of {number2} is {number2 ** 3}')
else:
   print(f'The square of {number2} is {number2 ** 2}')
if number3 % 2 == 0:
   print(f'The cube of {number3} is {number3 ** 3}')
else:
   print(f'The square of {number3} is {number3 ** 2}')

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS