I need this coded into a program that executes in Python and does the following.
ID: 3784752 • Letter: I
Question
I need this coded into a program that executes in Python and does the following.
A variable like userNum can store a value like an integer. Extend the given program to print userNum values as indicated. (Submit for 2 points).
(1) Output the user's input.
(2) Extend to output the input squared and cubed. Hint: Compute squared as userNum * userNum. (Submit for 2 points, so 4 points total).
(3) Extend to get a second user input into userNum2. Output sum and product. (Submit for 1 point, so 5 points total).
Explanation / Answer
1. Output the users input
userNum = input (' Enter Integer:')
Print "you entered", userNum
2. Extend to output the input squared and cubed.
userNum = input (' Enter Integer:')
Print "you entered", userNum
squar = userNum * userNum
cube = userNum * userNum * userNum
print ('{0} squared is {1} and {0} cubed is {2}'. format(userNum, squar, cube))
3. Extend to get a second user input into userNum2
userNum = input (' Enter Integer:')
Print "you entered", userNum
userNum1 = input (' Enter another Integer:')
add = userNum + userNum1
mul = userNum * userNum 1
Print('{0} + {1} is {2}'.format(userNum, userNum1, add))
Print('{0} * {1} is {2}'.format(userNum, userNum1, mul))
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.