How to Add Two Numbers in Python | Simple User Input Program Tutorial @LearningLad
How to Add Two Numbers in Python | Simple User Input Program Tutorial  @LearningLad
Uploaded September 2024 | Updated September 2026, 1 week ago
In this video, we will learn how to write a simple Python program that adds two numbers entered by the user.

First, we’ll ask the user to enter two numbers. To do this, we’ll use Python’s built-in input() function. This function allows us to display a message on the screen, and whatever the user enters will be captured as a string. For this program, we’ll prompt the user to enter the first number. However, since the input() function returns the user’s input as a string, we’ll need to convert that string into a numeric value using the float() function. This way, the user can enter both whole numbers and decimal numbers.

Next, we’ll read the second number the same way. After converting both inputs into float numbers, we’ll perform the addition operation using the + operator and store the result in a variable. Finally, we’ll display the result to the user using Python’s print() function.

To make the output user-friendly, we’ll format it using Python’s f-string syntax, showing the equation as a string (e.g., “22.2 + 33.3 = 55.5”).

In this tutorial, you’ll see how to write a clean and simple Python program to add two numbers, with user input and formatted output. We’ll even simplify the code by removing an unnecessary variable. You’ll also see the program in action as we run it and input different values.

Our Website
LearningLad.com

Social Media
Facebook facebook.com/LearningLad
Twitter twitter.com/LearningLadEdu
Instagram instagram.com/LearningLadOfficial
How to Add Two Numbers in Python | Simple User Input Program TutorialC Calculator Program Using Do While Loop & Switch Statement | Beginner TutorialSize Modifiers in C Programming | Short, Long & Unsigned Integers ExplainedHow to Install Python on Windows 11 (Latest Version) | Step-by-Step Guide for BeginnersWhat is a Structures | How to define Structures | C Language TutorialHow to Install C C++ Compiler / Tool set  ( gcc g++ gdb Mingw w64 ) Easily in Windows 11 ComputerDefining Structures Variables in Different ways in C Programming Language | TutorialSquare Pattern Printing with Diagonals in C Programming Language TutorialHow to install NumPy SciPy Pandas Matplotlib libraries for Python in Windows 10fprintf() Function to Write Data to a File :  C Programming Language Video TutorialInternal Working of For, While & Do While Loops in C | Explained with ExamplesHow to Build / Compile and Run a C Program in Command Prompt ( cmd ) on Windows 10
LearningLad |

How to Add Two Numbers in Python | Simple User Input Program Tutorial

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER