Q:

Python | Input two integers and find their addition

belongs to collection: Python basic programs

0

Input two integer numbers from the user and find their sum/addition in Python.

Example:

    Input:
    Enter A: 100
    Enter B: 200

    Output:
    Sum: 300

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program:

# input two numbers: value of a and b
a = int(input("Enter A: "))
b = int(input("Enter B: "))

# find sum of a and b and assign to c
c = a+b

# print sum (c)
print("Sum: ",c)

Output

Enter A: 100
Enter B: 200
Sum:  300

Explanation:

Here, we are reading two values and assigning them in variable a and b - to input the value, we are using input() function, by passing the message to display to the user. Method input() returns a string value, and we are converting the input string value to the integer by using int() method.

After that, we are calculating the sum of a and b and assigning it to the variable c. And then, printing the value of c which is the sum of two input integers.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Python basic programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Python program to find sum of two numbers... >>
<< Python | Program to define an integer value and pr...