The following example code shows a Program to Find Sum of Numbers Entered by the User in Python. To begin with, we need the input data from the user. In order to take input from users, we use the input() method of python. Also, we need variables to store user input. So, we take variables x and y. However, the input that we accept from the user is of type string. Because the input() method always returns a string. After that, we take another variable z. So, the variable z computes the sum. In order to convert the string type input to integer, we use the int() method of python. Hence, the variable z computes the integer sum. Otherwise, the ‘+’ operator concatenates the two input strings.

Finally, we use the print() method to display the sum. In order to concatenate, the string ‘Sum =’ with the sum we use the ‘+’ operator. However, it requires both operands to be strings. so, we convert the integer sum to a string. Therefore, we use the str() operator. Hence, we get the desired output.

Programmingempire

Illustrating Program to Find Sum of Numbers Entered by the User in Python

#program add.py that takes 2 numbers as input and prints its sum

x=input("Enter First Number: ")
y=input("Enter Second Number: ")
x=int(x)
y=int(y)
z=x+y;
print("Sum = "+str(z))

Output

The Output of the Program to Find Sum of Numbers Entered by the User in Python
The Output of the Program to Find Sum of Numbers Entered by the User in Python

Further Reading

Deep Learning Tutorial

Text Summarization Techniques

How to Implement Inheritance in Python

Find Prime Numbers in Given Range in Python

Running Instructions in an Interactive Interpreter in Python

Deep Learning Practice Exercise

Python Practice Exercise

Deep Learning Methods for Object Detection

Understanding YOLO Algorithm

What is Image Segmentation?

ImageNet and its Applications

Image Contrast Enhancement using Histogram Equalization

Transfer Learning and its Applications

Examples of OpenCV Library in Python

Examples of Tuples in Python

Python List Practice Exercise

Understanding Blockchain Concepts

Edge Detection Using OpenCV

Predicting with Time Series

Example of Multi-layer Perceptron Classifier in Python

Measuring Performance of Classification using Confusion Matrix

Artificial Neural Network (ANN) Model using Scikit-Learn

Popular Machine Learning Algorithms for Prediction

Long Short Term Memory – An Artificial Recurrent Neural Network Architecture

Python Project Ideas for Undergraduate Students

Creating Basic Charts using Plotly

Visualizing Regression Models with lmplot() and residplot() in Seaborn

Data Visualization with Pandas

A Brief Introduction of Pandas Library in Python

A Brief Tutorial on NumPy in Python

programmingempire