Basic Output with Variables

Basic Output with Variables

A variable like user_num can store a value like an integer. Extend the given program as indicated.

Output the user's input. (2 pts) Output the input squared and cubed. Hint: Compute squared as user_num * user_num. (2 pts) Get a second user input into user_num2, and output the sum and product. (1 pt)

Given:

user_num = int(input('Enter integer:\n'))

Type your code here

I have no idea where to start. I have looked through my resources and I dont know which coding formula to follow.

1

1 Answer

user_num = int(input('Enter integer:\n'))

print(user_num) # Output the user's input
print(user_num * user_num) # Output the input squared
print(user_num * user_num * user_num) # Output the input cubed

user_num2 = int(input('Enter another integer:\n')) #  Get a second user input into user_num2

print(user_num + user_num2) # output the sum

print(user_num * user_num2) # output the product

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

David Miller
Author

David Miller

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.