Python Program to Add Two Numbers

In this python program, we will learn how to add numbers using arithmetic operator

Add two numbers

1# python program to add two numbers 2a = 10 3b = 20 4 5add = a + b 6print(f"sum of a + b = {add}")

Output

1sum of a + b = 30

Add two numbers Using User Input

1# python program to add two numbers 2a = input("Enter first number: ") 3b = input("Enter second number: ") 4 5# Use type conversion to convert string to int data type 6a, b = int(a), int(b) 7 8add = a + b 9print(f"sum of a + b = {add}")

Output

1Enter first number: 5 2Enter second number: 15 3sum of a + b = 20