Today I am Writing a blog on the topic “Python 3.11.1 Programming to Add Two Numbers”
Python 3.11.1 is a popular programming language for beginners and experienced programmers. In this blog, I (DDSRY) will explain you, “how to write a program in Python to add two numbers”.
Lets start coding, create a simple program that takes two numbers, take input from the user, adds them together, and displays the sum of it, result. To do this, will make use built-in function “input()” which allows us to take input from the user, and the “+” operator which is used for addition in Python.
num1 = int(input(“Enter the first number: “))
num2 = int(input(“Enter the second number: “))
sum = num1 + num2
print(“The sum of”, num1, “and”, num2, “is”, sum)
This code is easy to read and understand, even for someone who is new to programming, all because of python 3.11.1 programming language.
The “input()” function takes the user’s input as a word, sentences, (string), so we use the “int()” function to convert it to an integer, which is the type of datatype that we need to write in our code, mathematical operations.
Sum of the two numbers is calculated using the plus “+” operator and get stored in the variable “sum”. Finally, the output (result) of our code is displayed using the “print()” function by python, which use to display text on output screen.