Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Addition | Arithmetic operations
Learn Python from Scratch
Sectionย 2. Chapterย 1
single

single

bookAddition

Swipe to show menu

Addition in Python is easy - just use "+" sign. You can add numbers or variables (or mix of numbers and variables).

1234
a = 1 b = 2 c = a + b print(c)
copy

Sometimes people use alternative operator: "+=" (it is typically used for brevity). Please see example below (this basically means "increase variable on the left hand side by 1"):

123
x = 100 x+=1 print(x)
copy
Task

Swipe to start coding

Add line to print the sum of 20 and 22.

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Sectionย 2. Chapterย 1
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

some-alt