Main menu

Pages

Learn Python #2 Numbers in Python

 

Learning Python #2
Numbers in Python



We learnt in the previous lesson the print statement and how to deal with strings.


What will we learn in this lesson?

- Dealing with Numbers in Python


Keywords: Python, programing, numbers, integers, float.


Let's go:

    Python has three numeric data-types which are: Integers (int), Floating-point (float) and and Complex numbers.

1) An integer: is a number with no decimal or fractional part, from the set of negative and positive numbers, including zero. Examples of integers are: -5, 0, 1, 5, 8, 97, and 3,043.

2) The floating-point is the number that contains floating decimal points. For example, the numbers 5.5, 0.001, and -2,345.6789.

3) The complex number is the number that can be expressed in the form a + bi, where a and b are real numbers, and i is a symbol called the imaginary unit, and satisfying the equation i2 = −1. For example, −1 + 3i .


Many methods and functions can be used when dealing with number as:


Where we use:
type   : to identify the data type of a number.
int      : to change float to integer.
float   : to change int to float.
round :to round a number to the nearest given digit.
abs     :to get the absolute value of a number.
Where we use:
+  : for addition.
-   : for subtraction.
*  : for multiplication.
/   : for division.
//  : for integer division.
: for modulus (the remainder of a division).
**: for power.


author-img
Yet another human being that's passionate about Data Science, AI, programming & Math.

Comments

1 comment
Post a Comment

Post a Comment