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 numbers” are 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:
The system of the binary conversion
The binary number system defines a number in a binary system. You only find the number in a two-number system the 1 and the 0. The binary number system is an alternative system of representation to the decimal number system. The decimal number system is from (0 to 9) and has a base of 10…
What is web development for beginners?
Introduction In web development, we refer to website so web development refers to website development. “Web” word has been taken from the spider’s web because of the analogy that like a web is connected similarly websites are also connected to each other through the Internet. History of web development 1989: Proposal for the World Wide…
Guide to Proxy Servers: How They Work and Why You Need Them?
What is a web proxy? During our college days, we often heard the term “proxy” which referred to the act of someone else marking our attendance, allowing us to be present in a class even if we were not physically there. In the context of the Internet, a web proxy works similarly, acting as an…
Continue Reading Guide to Proxy Servers: How They Work and Why You Need Them?
Python | Check Armstrong Number using for loop
An Armstrong number is a number that is equal to the sum of its own digits raised to the power of the number of digits. Consider 153. It has 3 digits, so we raise each digit to the power of 3(the number of digits) and sum them up:1^3 + 5^3 + 3^3 = 1 +…
Continue Reading Python | Check Armstrong Number using for loop
Python | Factorial of a number using for loop
The factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. The factorial of 0 is defined to be 1. The factorial formula can be expressed as: n! = 1 * 2 * 3 * … * n Code to calculate factorial of…
Continue Reading Python | Factorial of a number using for loop
Link in bio
Python Mega Course 2023 Radha Krishna Python Code