How to make an addition in Python
Learn how to add numbers in Python with this easy example: "print(2 + 2) # 4".
Adding two numbers in Python
Python makes it easy to add two numbers together. To add two numbers together, use the plus symbol (+).
For example, to add 5 and 7 together, type the following into the Python shell:
5 + 7
This will return the result of 12:
12
You can also add more than two numbers together. For example, to add 5, 7, and 10 together, type the following into the Python shell:
5 + 7 + 10
This will return the result of 22:
22
You can also add variables together. For example, if you have two variables, x and y, that contain the values 5 and 7 respectively, then you can add them together by typing the following into the Python shell:
x + y
This will return the result of 12:
12
Python makes it easy to add numbers and variables together. With just a few lines of code, you can quickly and easily add two or more numbers together.