In this program, we are going to make a simple python program that will add two numbers with user input. We will take numbers from users or else we can also hard code values.

Pre-requisite: Syntax to print Output in python

I am using f-string to print our result. f-string is a simple print statement that helps us to print variables along with string. We have to just use curly braces to print variables. It starts with the prefix f.
For example:

A=7
print(f"Number A is {A}")

## How to write a program to add two numbers in python with user input

In this example, we take input from the user which is by default of string type so we will typecast them to int. Then we will add and print them.
first=int(input("Enter first Number: "))
second=int(input("Enter Second Number: "))

sum=first+second
print(f"{first} + {second} = {sum}")
Output:

Enter first Number: 56
Enter Second Number: 44
56 + 44 = 100

## Simple Python Program to Add Two Numbers

In this example, we will add two numbers in python and print their sum.
a=5
b=10
sum=a+b
print(f"{a} + {b} = {sum}")
Output:

5 + 10 = 15

first=int(input("Enter first Number: "))
num=first
second=int(input("Enter Second Number: "))
num2=second

while second != 0:

temp = first & second
first = first ^ second
second = temp << 1
print(f"{num} + {num2} = {first}")
Output:

Enter first Number: 57
Enter Second Number: 87
57 + 87 = 144

## Python Program to Add Two Numbers using function

In this example, we will make a function that will return the addition of two numbers. It takes two numbers in arguments. We can also print the sum of numbers in our function.
return num1+num2

num1=int(input("Enter first Number: "))
num2=int(input("Enter Second Number: "))

## Python program to add two numbers using class

def __init__(self, a, b):
self.a = a
self.b = b
self.sum()

def sum(self):
print(f"The sum of {self.a} & {self.b} is {self.a+self.b}")

num1 = int(input("Enter first Number: "))
num2 = int(input("Enter Second Number: "))