Variables
Operations on Variables
- Beginner
- January 5, 2026
Explore how to perform various operations on Python variables including arithmetic operations like addition and string concatenations. Understand how to store results in variables and prepare for more advanced operator concepts in programming.
Applying operations on variables
It’s common to apply operations on variables depending on their type. Arithmetic operations such as summation are performed on numbers, while string operations like concatenation are performed on strings. We will learn more about these types in the Data Types lesson.
Integer operations
For example, one variable can be used to save the result of applying an operation on a single or group of variables. We can save the result obtained by the addition of two numbers num_one and num_two in a third variable called sum.
num_one = 55
num_two = 45
sum = num_one + num_two
print(sum)
Integer operations in Python
Note: There are numerous other operations that Python provides us with, which we will be learning in the upcoming operator section.
String operations
Let’s also concatenate two different strings together into a single string called new_string.
new_string = "You are" + " learning variables!"
print(new_string)
String operations in Python
Note: If you want to add a space during concatenation, you’ll have to add it in the second string.
Just like this, you can perform any required operation on variables.
In This Module