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.


Expert's answer

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}')
LATEST TUTORIALS
APPROVED BY CLIENTS