total = 4 + 3Line-by-line explanation
4is the first number.+means add.3is the second number.- The result
7is stored intotal.
Python uses + for addition, - for subtraction, * for multiplication, and / for ordinary division.
pieces = 12 // 5Line-by-line explanation
12is divided by5.//means whole-number division.- The result is
2; the leftover part is removed.
% gives the remainder, and ** raises a number to a power. Parentheses make the order of a calculation clear.
result = (2 + 3) * 4Line-by-line explanation
- The parentheses make
2 + 3happen first. - That result is multiplied by
4. resultstores20.