Skip to Content
Learn Python by Building Data Science Applications
book

Learn Python by Building Data Science Applications

by Philipp Kats, David Katz
August 2019
Beginner
482 pages
12h 56m
English
Packt Publishing
Content preview from Learn Python by Building Data Science Applications

Floats and integers

Floats and integers represent rational numbers with and without a decimal part, respectively. Those types are quite intuitive to use, as they can be added, subtracted, multiplied, divided, and more. Let's take a look at the following example. First, we assign two variables:

A = 6B = 5

Now, let's go over some possible operations:

>>> A + B11>>> A - B1>>> A / B1.2>>> A * B30

You can also raise numbers to a power by using double asterisks:

>>> 2**38>>> 3**29

You might have noticed that the division of two integers will result in a float. This happens even if the remainder is zero:

>>> 10 / 25.0

If you need to keep the integer division result as an integer (rounded, if needed), then use a double slash instead; this operation ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python for Data Science

Python for Data Science

Yuli Vasiliev
Introduction to Machine Learning with Python

Introduction to Machine Learning with Python

Andreas C. Müller, Sarah Guido

Publisher Resources

ISBN: 9781789535365Supplemental Content