dazedandconfused
dazedandconfused

Reputation: 33

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

Upvotes: 0

Views: 33566

Answers (4)

AFM
AFM

Reputation: 1

person_name = input()
person_age = int(input())

Upvotes: 0

Nik P
Nik P

Reputation: 89

in fact you need just:

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

Upvotes: 0

Athena
Athena

Reputation: 3228

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.

Upvotes: 0

sir_snoopalot
sir_snoopalot

Reputation: 169

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().

Upvotes: 4

Related Questions