Perform simple arithmetic Python 3


show more Performing simple arithmetic provides you with in-depth training on Developer. Taught by Bill Weinman as part of the Python 3 Essential Training show less
please wait ...

Performing simple arithmetic

In this chapter, as we look at operators in Python, we are going to be using the Python Shell which is called Idle in a graphical environment, or in a text environment, it's simply the Python Interpreter, run from the command line. Python has all of the standard arithmetic operators. For example, if you say 5 + 5, you get 10. If say 5 * 5, you get 25. If you say 5 - 3, you get 2, and if you say 5 / 3, you get this 1.666.

Python also has some thing that they call floor division, which is simply integer division. If I say 5 with two slashes divide by three then I get 1, which, of course, has a remainder as well. So if I say 5 with a percent sign from modulo and a 3, then I get the remainder. Python also has a built-in function called divmod that gives the two results together. So if we say Divmod(5, 3), then you get both of those results together as a tuple.

Finally, Python has increment and decrement operators, and they are not quite the same as you see in some other scripting langua...

Performing simple arithmetic
Video duration: 2m 14s 6h 36m Beginner

Viewers:

Performing simple arithmetic provides you with in-depth training on Developer. Taught by Bill Weinman as part of the Python 3 Essential Training

Subjects:
Developer Web
Software:
Python
Author:
please wait ...