Arithmetic Operators in Python

Arithmetic operators are fundamental building blocks in any programming language, and Python is no exception. They allow us to perform various mathematical calculations, such as addition, subtraction, multiplication, division, and more.

In this module, we will dive deep into the world of arithmetic operators in Python, providing code examples and detailed explanations along the way.

Addition Operator (+)

The addition operator (+) is used to add two or more numerical values together. It can also be used to concatenate strings ( we already covered this in detail in our Strings module). Let's look at some examples:

 >>> # Numeric addition
 >>> result = 5 + 3
 >>> print(result)
 >>> # Output: 8
 >>> # String concatenation
 >>> greeting = "Hello, "
 >>> name = "John"
 >>> message = greeting + name
 >>> print(message)
 >>> # Output: Hello, John
500 Internal Server Error

500 Internal Server Error