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:

Write for CopyAssignment.com | Unlock Your Potential: Join CopyAssignment.com as a Blog Writer! 🚀

Are you a passionate and knowledgeable individual in the field of computer science, programming, technology, or related subjects? Do you have a flair for writing and a desire to share your insights with the world? If so, we have an exciting opportunity for you! CopyAssignment.com, a leading platform in the programming niche, is on the…

Continue Reading Write for CopyAssignment.com | Unlock Your Potential: Join CopyAssignment.com as a Blog Writer! 🚀

Python 3.12.1 is Now Available

Thursday, December 7, 2023 Python enthusiasts, rejoice! Python 3.12.1, the first maintenance release of Python 3.12, is now available for download here. This update packs over 400 bugfixes, build enhancements, and documentation changes since 3.12.0. The 3.12 series introduces major features, including: More flexible f-string parsing (PEP 701). Buffer protocol support in Python code (PEP…

Continue Reading Python 3.12.1 is Now Available

Best Deepfake Apps and Websites You Can Try for Fun

Deepfake is one technology that remains consistently impressive. Apps like Lensa AI have taken the internet by storm. It lets you create deepfake portraits within minutes, and the results look incredibly authentic. While deepfake apps are for fun, deepfake videos can be deeply problematic if used for misrepresenting someone, particularly in politics. So in this…

Continue Reading Best Deepfake Apps and Websites You Can Try for Fun

Amazon launched free Prompt Engineering course: Enroll Now

Introduction In this course, you will learn the principles, techniques, and the best practices for designing effective prompts. This course introduces the basics of prompt engineering, and progresses to advanced prompt techniques. You will also learn how to guard against prompt misuse and how to mitigate bias when interacting with FMs. Course objectives In this…

Continue Reading Amazon launched free Prompt Engineering course: Enroll Now

Hello World in 35 Programming Languages

A timeless custom known as the “Hello, World!” program marks the start of every programmer’s adventure in the wide world of programming. This surprisingly easy article examines the various ways that 35 different programming languages express this well-known statement. Every “Hello, World!” implementation offers a glimpse into the distinct syntax and personality of the language…

Continue Reading Hello World in 35 Programming Languages