Python Numeric Datatypes

There are three Python Numeric Datatypes int, float, complex, and in mathematics, these are represented as integers, decimals, and complex numbers.

Example

x = 12
y = 12.3
z = 12j  # we use "j" to represant complex numbers
print(type(x))
print(type(y))
print(type(z))

Output

<class 'int'>
<class 'float'>
<class 'complex'>

Int

In Python int, or integer is a whole number(positive, negative, and zero) and the length is unlimited.

Example

x = 1227348742474
y = -12234353546
z = 0
print(type(x))
print(type(y))
print(type(z))

Output

<class 'int'>
<class 'int'>
<class 'int'>

Float

In Python “Float or “floating-point numbers” are similar to decimal numbers in maths.

Example

x = 122734.8742474
y = -12234.353546
z = 0.2032
print(type(x))
print(type(y))
print(type(z))

Output

<class 'float'>
<class 'float'>
<class 'float'>

Complex

In Python, “complex numbersare created using “j” after a number.

Example

x = 12 + 3j
y = -12 - 0.4j
z = 4j
print(type(x))
print(type(y))
print(type(z))

Output

<class 'complex'>
<class 'complex'>
<class 'complex'>

Also Read:

Make money with Python in 2022

Did you know that data science was the fifth most common job on LinkedIn in 2017? Did you know that the demand for Python programmers is expected to grow by 19% from 2020-2021? Did you know that Python is one of the fastest-growing programming languages, and it will likely continue to expand as its adoption…

Continue Reading Make money with Python in 2022

Top 15 Python Libraries For Machine Learning in 2022

Introduction  In today’s digital environment, artificial intelligence (AI) and machine learning (ML) are getting more and more popular. Because of their growing popularity, machine learning technologies and algorithms should be mastered by IT workers. Specifically, Python machine learning libraries are what we are investigating today. We give individuals a head start on the new year…

Continue Reading Top 15 Python Libraries For Machine Learning in 2022

Team Points in Python | Assignment Expert

Problem Statement: This is IPL and matches are going on. You are a programmer who writes programs to output summarized charts of matches already played.You will be given some input and you need to print a summarized chart in descending order of points. Points criteria->Match won-> 2Draw-> 1Loss-> 0 For exampleInput:4RR-RCB-lossMI-KKR-lossCSK-RR-winGT-RCB-drawOutput:Team: RR | Total Matches:…

Continue Reading Team Points in Python | Assignment Expert