Practice With Arithmetic Operators

Practice these programming examples to internalize these concepts.

1. How To Do Math with Operators

Numbers are extremely common in programming. They are used to represent things like screen size dimensions, geographic locations, money and points, the amount of time that passes in a video, positions of game avatars, and colors through assigning numeric codes.

Being able to effectively perform mathematical operations in programming is an important skill to develop because of how frequently you'll be working with numbers. Though a high-level understanding of mathematics can certainly help you become a better programmer, it is not a prerequisite. If you don't have a background in mathematics, try to think of math as a tool to accomplish what you would like to achieve, and as a way to improve your logical thinking.

We'll be working with two of Python's most used numeric data types, integers and floats:

  • Integers are whole numbers that can be positive, negative, or 0 (…, -101, …).
  • Floats are real numbers, they contain a decimal point (as in 9.0 or -2.25).

This tutorial will go over operators that can be used with number data types in Python.

Source: Lisa Tagliaferri,
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 License.