3.3. Summary of Expression TypesΒΆ

Expression

Arithmetic meaning

1 + 2

Addition, the result is 3

3 * 4

Multiplication, the result is 12

1 / 3

Integer division, the result is 0 in older Python environments, but 0.333333333333 in Python 3

2.0 / 4.0

Division, the result is 0.5, since you are using decimal numbers in the calculation

2 % 3

Modulo (remainder), the result is 2

-1

Negation, the result is -1

Before you keep reading...

Making great stuff takes time and $$. If you appreciate the book you are reading now and want to keep quality materials free for other students please consider a donation to Runestone Academy. We ask that you consider a $10 donation, but if you can give more thats great, if $10 is too much for your budget we would be happy with whatever you can afford as a show of support.

Note

Discuss topics in this section with classmates.

Show Comments
You have attempted 1 of 4 activities on this page