Answer to Question #300097 in Python for Christine

Question #300097

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 of 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 complete coding of this. Thank you

1
Expert's answer
2022-02-21T01:27:53-0500
numbers = []

for i in range(1, 4):
    print(f'Enter number {i}: ', end='')
    x = input()
    if x.isdigit():
        numbers.append(int(x))
    else:
        print('You entered not a number!')

for i in range(len(numbers)):
    x = numbers[i]
    print(f'\n\nNumber {i+1}: {x}')
    if x % 2 == 1:
        print(f'The square of {x} is {x*x}')
    else:
        print(f'The cube of {x} is {x*x*x}')

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