Read User Input Numbers and Perform a Calculation in Python

please help me... "Read in two numbers from user input without a prompt, add them, and print the result. Hint: Use int() to convert the numbers to integers.

Note: These activities may test code with different test values. This activity will perform two tests: the first with num1 = 5 and num2 = 10, the second with num1 = 6 and num2 = 3. "

I tried just doing one and it didn't work but I can't wrap my head around how to do two tests let alone one... I tried this so far and it came out with 510..noob please help

num1=int(input(5)) 
num2=int(input(10))
num3=num1 + num2
1

The argument to the input() function is the string to display as a prompt.

In your case, you'd want that to be simply input().

4

in fact you need just:

num1 = int(input())
num2 = int(input())
num3 = num1+num2
print(num3)

Don't pass parameters into input. You're asking the user for input.

I don't think the assignment is asking you to write your own tests. I think it's saying that whatever code you give it will be tested.

person_name = input()
person_age = int(input())
1
David Miller

David Miller

Executive Financial & Market Analyst

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.

Share this article
Twitter Facebook Pinterest