admin@mazurekgravity.in

Read two numbers from user input. Then, print the sum of those numbers. Hint — Copy/paste the following code, then just type code where the questions marks are to finish the code.num1 = int(input()) num2 = ? print(num1 + ?) Note: Our system automatically runs your program several times, trying different input values each time to ensure your program works for any values. Notes on how to solve this. This was my answer: num1 = int(input(‘5′)) num2 = int(input(’10’)) print(num1 + num2) This was the issue: Testing with 5 + 10 Output differs. See highlights below. Your output 51015 Expected output 15

Question-AnswerCategory: Computer ScienceRead two numbers from user input. Then, print the sum of those numbers. Hint — Copy/paste the following code, then just type code where the questions marks are to finish the code.num1 = int(input()) num2 = ? print(num1 + ?) Note: Our system automatically runs your program several times, trying different input values each time to ensure your program works for any values. Notes on how to solve this. This was my answer: num1 = int(input(‘5′)) num2 = int(input(’10’)) print(num1 + num2) This was the issue: Testing with 5 + 10 Output differs. See highlights below. Your output 51015 Expected output 15
JaCk asked 1 year ago

Read two numbers from user input. Then, print the sum of those numbers.
Hint — Copy/paste the following code, then just type code where the questions marks are to finish the code.num1 = int(input()) num2 = ? print(num1 + ?)
Note: Our system automatically runs your program several times, trying different input values each time to ensure your program works for any values. Notes on how to solve this.
This was my answer:
num1 = int(input(‘5′))
num2 = int(input(’10’))
print(num1 + num2)
This was the issue:

Testing with 5 + 10

Output differs. See highlights below.

Your output
51015

Expected output
15

1 Answers
DynA answered 1 year ago

 

Read two numbers from user input. Then, print the sum of those numbers.

Hint — Copy/paste the following code, then just type code where the questions marks are to finish the code.num1 = int(input()) num2 = ? print(num1 + ?)

Note: Our system automatically runs your program several times, trying different input values each time to ensure your program works for any values. Notes on how to solve this.
This was my answer:
num1 = int(input(‘5′))
num2 = int(input(’10’))
print(num1 + num2)
This was the issue:

Testing with 5 + 10

Output differs. See highlights below.

Your output
51015

Expected output
15

clearTest aborted

 

Explanation:

The solution code is written in Python:
1. num1 = int(input(“Enter first number: “))
2. num2=int(input(“Enter second number: “))
3. print(num1 + num2)
Firstly, we use input function to prompt user input first and second number (Line1 and 2).
We can include the prompt message as the argument of input function. Besides, we also convert the input to integer type using int() function. By default all the input are string.
At last, use print function to display the result of num 1 + num2 (Line 3)

Code screenshot:

Computer Science homework question answer, step 3, image 1

Output:

Computer Science homework question answer, step 4, image 1

Your Answer

20 + 15 =