Python How To Add Two Numbers Together Easy Guide

Logan Jul 13, 2026

In the dynamic world of programming, Python has emerged as a popular language, renowned for its readability and efficient syntax. Today, we're going to delve into a fundamental topic: adding two numbers together in Python. This seemingly simple operation encapsulates the essence of programming - using a few lines of code to accomplish what could take humans much longer. So, let's get started!

Simple Python Program to add Two number
Simple Python Program to add Two number

Before diving into the code, let's understand why we might want to add two numbers. In programming, addition is integral to calculations, data manipulation, and algorithm development. For instance, you might use addition to find the total of a list of numbers, to increment a counter, or to perform calculations in a scientific simulation.

Sum of Two Numbers in Python or Adding Two Numbers
Sum of Two Numbers in Python or Adding Two Numbers

Basic Addition in Python

Let's start with the basics. In Python, you can add two numbers using the plus sign (+). It's that simple! Here's how you can do it:

PYTHON program to SWAP numbers
PYTHON program to SWAP numbers

Syntax: num1 + num2

Integer Addition

a book cover with the title, 5 ways to draw numbers in python and other languages
a book cover with the title, 5 ways to draw numbers in python and other languages

First, let's consider integers. Python supports both decimal and hexadecimal integers. Here's an example:

Example: ```python num1 = 10 num2 = 5 print(num1 + num2) # Output: 15 ```

Float Addition

All Important Python Functions for Beginners (Complete Cheat Sheet)
All Important Python Functions for Beginners (Complete Cheat Sheet)

Python also supports addition of floating-point numbers. These are numbers with decimal points, like 3.14. Here's an example:

Example: ```python num1 = 3.14 num2 = 2.71 print(num1 + num2) # Output: 5.85 ```

Addition with Variables

an image of a computer screen with the text 2 without using a temporary variable
an image of a computer screen with the text 2 without using a temporary variable

In programming, you'll often want to add variables together rather than fixed values. This is where the power of programming really shines. Let's explore this:

Adding Two Variables

a man holding up a poster with the words 5 levels of python on it
a man holding up a poster with the words 5 levels of python on it
Phyton
Phyton
the top 50 python project ideas
the top 50 python project ideas
📘 Python for Beginners Notes 🐍🔥
📘 Python for Beginners Notes 🐍🔥
"6 Python List Methods Every Beginner Should Know"
"6 Python List Methods Every Beginner Should Know"
Top 5 Python Projects for Beginners 🚀 (Start Coding Today)
Top 5 Python Projects for Beginners 🚀 (Start Coding Today)
Address Book Project in Python with Source Code
Address Book Project in Python with Source Code
5 Python Tricks That Will Save You Hours of Coding
5 Python Tricks That Will Save You Hours of Coding
Python Tip: Use zip() Like a Pro 🐍
Python Tip: Use zip() Like a Pro 🐍
three different types of python programming
three different types of python programming
Python list exercises guide
Python list exercises guide
Addition and subtraction of datetime with time in Python
Addition and subtraction of datetime with time in Python
a poster with the words python master notes written in different languages and numbers on it
a poster with the words python master notes written in different languages and numbers on it
Python Data Structures Cheat Sheet for Beginners (Lists, Tuples, Sets & Dictionaries)
Python Data Structures Cheat Sheet for Beginners (Lists, Tuples, Sets & Dictionaries)
Python Functions Cheat Sheet
Python Functions Cheat Sheet
9 Python Loop Tricks Every Beginner Should Learn (Cheat Sheet)
9 Python Loop Tricks Every Beginner Should Learn (Cheat Sheet)
python
python
Tuples in Python; and how to create and access items form  it | Python Programming
Tuples in Python; and how to create and access items form it | Python Programming
Python Operators Tutorial – Chapter 3 Notes
Python Operators Tutorial – Chapter 3 Notes

Python allows you to add two variables by simply assigning the sum to a new variable, or performing the operation directly in a print statement. Here's how:

Example: ```python a = 5 b = 10 c = a + b # Sum is stored in 'c' print(c) # Output: 15 # Alternatively, you can directly print the sum: print(a + b) # Output: 15 ```

Nested Addition

Python supports nested addition, allowing you to perform multiple addition operations within a single expression. This comes in handy when working with complex equations. Here's an example:

Example: ```python d = a + b + c # This will add the values of 'a', 'b', and 'c' together print(d) # Output: 30 ```

Addition isn't limited to numbers. In Python, you can also add strings together using the + operator, resulting in concatenation. But that's a topic for another time!

So, there you have it - a comprehensive guide on how to add two numbers together in Python. Whether you're performing basic arithmetic or writing complex algorithms, mastering addition is a fundamental step in your programming journey. Now, go forth and start coding! Remember, practice makes perfect, so keep exploring, experimenting, and refining your skills. Happy coding!"