In a modify task you take code that already works and adapt it so that it does something else. This time the starter code does not work at all: it stops with an error before it outputs anything. Your first job is to find out why.
The editor starts you off with this program:
num1 = 10
num2 = input
total1 = num1 + num2
print(str(num1) + " plus " + str(num2) + " = ")
Adapt the code so that it adds and multiplies the two numbers, and outputs both results.
num2 line creates an error. Look carefully at what is wrong with it: it
never actually collects anything from the user, and what it collects has to be
a number rather than text before it can be added up.print, exactly as written below,
followed by an input() on the next line that collects the answer.print line so that the sum stored in total1 is concatenated
onto the end of it.num1 and num2 together
and assign the result to it.num1, num2 and your new variable in the same format as the line
above, using the word times where the first line uses plus.Ask the question with its own print, exactly as written:
Enter a number:
The question is part of the checked output, so spelling, capital letters and
punctuation count. The two output lines that follow it must also match exactly,
spaces and the = included. For a user who enters 5, the program outputs:
Enter a number:
10 plus 5 = 15
10 times 5 = 50
Input:
48
Output:
Enter a number:
10 plus 48 = 58
10 times 48 = 480
Input:
-6
Output:
Enter a number:
10 plus -6 = 4
10 times -6 = -60
Make sure that you check for the following things:
= for assignment.+ to add, - to subtract, * to
multiply, / to divide with a decimal result, and // to divide and keep
only the whole number part.input.print is wrapped in str().