Numbers in Python (Int, Float, Complex, Boolean) – Python Data Types

🎓 Welcome back to Digital Academy, the Complete Python Development Tutorial for Beginners, which will help you Learn Python from A to Z!

🖥️ Numerical Data Types in Python

In Python, numeric data type represent the data which has numeric value. Numeric value can be: Integer or Floating numbers, even Complex numbers. These values are defined as int, float and complex class in Python. We can use the type() function, to know which class a variable or a value belongs to. And the isinstance() function, to check if an object belongs to a particular class. You can convert from one type to another with the int(), float(), and complex() methods.

Integers

This value is represented by int class. It contains positive or negative numbers (without fraction or decimal). In Python 3, Integers can be of any length, it is only limited by the amount of memory your system has, as are all things. But beyond that, an integer can be as long as you need it to be.

Python interprets a sequence of decimal digits without any prefix to be a decimal number. But the following strings can be prepended to an integer value, to indicate a base other than 10:

Prefix Interpretation Base
0b (zero + lowercase letter 'b') Binary 2
0o (zero + lowercase letter 'o') Octal 8
0x (zero + lowercase letter 'x') Hexadecimal 16


○ Floating point Numbers

This value, represented by float class, designates a floating-point number. It is a real number, with the floating point representation, and is specified with a decimal point. Optionally, the character ‘e’, followed by a positive or negative integer, may be appended, to specify the scientific notation. This representation is accurate up to 15 decimal places.

○ Complex Numbers

Complex Numbers, represented by complex class, is written in the form, (real part) + (imaginary part)j. It is stored internally, using either rectangular or Cartesian coordinates. It can be very useful if you are studying or working with mathematical functions, or in engineering. For example: 2+3j

○ Boolean Values

Python 3 provides a Boolean data type. Objects of Boolean type may have one of two values, True or False.

In programming you often need to know if an expression is True or False. You can evaluate any expression in Python, and get one of these two answers. For instance, when you compare 2 values, the expression is evaluated, then Python returns the Boolean answer. The same behaviour occurs, when you run a condition in an if statement.

Python also has many built-in functions that returns a boolean value, like the isinstance() function, which can be used to determine if an object is of a certain data type. You will learn more about evaluation of objects in the Boolean context, when you encounter logical operators, in the upcoming tutorial on operators, and expressions in Python.

Let’s play this video, stick around and watch until the end of this video! 👍🏻

– Digital Academy™ 🎓

***

☞ WATCH NEXT:
○ Data Types in Python – https://youtu.be/cweUByxBWiU
○ Operators in Python – https://youtu.be/-wDaVLkKOiU
○ IF Statements in Python – https://youtu.be/CC5seZ6OBJ4
○ FOR Loops in Python – https://youtu.be/JgH-D5DSTho

☞ WATCH MORE:
○ HOW TO Learn Python? Python Tutorial for Beginners [FULL Course] https://youtu.be/9hvnSZPMtuw

📖 Blog: http://digital.academy.free.fr/blog/

📖 Complete Python Development Course for Beginners [PLAYLIST]: http://digital.academy.free.fr/playlist/python-development-for-beginners

#Python #Tutorial #Beginners #Shorts

***

♡ Thanks for watching and supporting ♡
Please Subscribe. Hit the notification bell.
Like, Comment and Share.

***

♡ FOLLOW US ♡
http://digital.academy.free.fr/
https://twitter.com/DigitalAcademyy
https://www.facebook.com/digitalacademyfr
https://www.instagram.com/digital_academy_fr/
https://www.youtube.com/c/DigitalAcademyOnline

♡ SUPPORT US ♡
http://digital.academy.free.fr/join
http://digital.academy.free.fr/donate
http://digital.academy.free.fr/subscribe
https://www.patreon.com/digital_academy
https://www.buymeacoffee.com/digital_academy

***

Copy link
Powered by Social Snap