0% found this document useful (0 votes)
3 views

001 Python-Numbers-Integers-and-Floats

Python Numbers Integers and Floats

Uploaded by

m.a.abrache
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

001 Python-Numbers-Integers-and-Floats

Python Numbers Integers and Floats

Uploaded by

m.a.abrache
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Numbers in Python Programming

With this section, now, we are starting to learn Python. First of all, we need to learn data types and data structures to
solidify our Python knowledge.

Let's start with our Python journey by learning the numbers in Python.

In this lesson, we are going to learn following topics:

Integers Data Type


Floating Point Numbers
Basic Math Operations

Integers
Integers are like whole numbers, but they also include negative numbers ... In integers no fractions allowed!

So, integers can be negative {-1, -2,-3, -4, -5, ... }, zero {0} and positive {1, 2, 3, 4, 5, ... }

We can put that all together like this:

Integers = { -∞,...,-6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6...,∞ }

Examples: −16, 35, 0, 7, 198 ... are all integers.

Floats (Floating Points)


Floating-points are numbers with floating decimal points.

Floating-point, as the name implies, are numbers that contain decimal points that can float left or right.

In programming, floating-point is used to represent fractions. Numbers such as 1/2, 3/7, -100/3 can be represented in
floating-point as 0.5, 0.42857, -33.33.

Often the keyword float is used to declare a variable that stores floating-point numbers.

Examples: 2.4, -1.62, 3.14, -0.1, 3.554546, -13.58

Now let's learn the basic mathematical operations in Python programming.

Basic Math Operations


Basic math operations include four basic operations:

Addition (+)
Subtraction (-)
Multiplication (*)
Division (/)

These operations are commonly called arithmetic operations. Arithmetic is the oldest and most elementary branch of
mathematics. In this lesson we will briefly explain basic math operations. Keep in mind that, even though the operations
and the examples shown here are pretty simple, they provide the basis for even the most complex operations used in
mathematics.

The Complete Python Programming Course (Beginner to Advanced)


In [2]: #Addition
3 + 4

Out[2]: 7

In [3]: #Substraction
2 - 5

Out[3]: -3

In [4]: #Multiplication
2 * 11

Out[4]: 22

In [5]: #Division
6 / 3

Out[5]: 2.0

So far, we have learned our basic math operations. But the last operation, the division may have confused in your mind.

6 is an integer, 3 is an integer too. So why the result is a float? I think it would be much better to see them in the
Mathematical Operators section.

In [7]: 3 + 5 + 9 - 4 * 3

Out[7]: 5

That's all for now for this lesson!

See you in our next lessons!

The Complete Python Programming Course (Beginner to Advanced)

You might also like