What is a Numeric Data Type in Python | EP-28 Numeric Data Types in Python | Python Data Types

Veröffentlicht am: 19 August 2024
auf dem Kanal: Cybrosys Technologies
105
0

NUMERIC DATATYPE
"""In Python, “Numberic datatype” is a category that has different types of numeric data.
Python supports various types of numbers, including integers, floating-point numbers, and complex numbers.
Table of Content

Python Integer
Python Float
Python Complex
Type Conversion in Python
Decimal Numbers in Python"""
1.Python Integer
"""
Python int is the whole number, including negative numbers but not fractions.
In Python, there is no limit to how long an integer value can be."""

Creating int and checking type
num = -8

print the data type
print(type(num))

Performing arithmetic Operations on int type
a = 5
b = 6

Addition
c = a + b
print("Addition:",c)

d = 9
e = 6

Subtraction
f = d - e
print("Subtraction:",f)

g = 8
h = 2

Division
i = g // h
print("Division:",i)

j = 3
k = 5

Multiplication
l = j * k
print("Multiplication:",l)

m = 25
n = 5

Modulus
o = m % n

print("Modulus:",o)

p = 6
q = 2

Exponent
r = p ** q
print("Exponent:",r)

2. Python Float
"""
This is a real number with a floating-point representation. It is specified by a decimal point.
Optionally, the character e or E followed by a positive or negative integer may be appended to specify
scientific notation. . Some examples of numbers that are represented as floats are 0.5 and -7.823457.

They can be created directly by entering a number with a decimal point, or by using operations such as
division on integers. Extra zeros present at the number’s end are ignored automatically."""

Creating float and checking type


num = 3/4
print the data type
print(type(num),num)

"""As we have seen, dividing any two integers produces a float. A float is also produced by running an
operation on two floats, or a float and an integer."""
num = 6 * 7.0

print(type(num))

Performing arithmetic Operations on the float type


a = 5.5
b = 3.2

Addition
c = a + b
print("Addition:", c)

Subtraction
c = a-b
print("Subtraction:", c)

Division
c = a/b
print("Division:", c)

Multiplication
c = a*b

print("Multiplication:", c)

"""Note : The accuracy of a floating-point number is only up to 15 decimal places, the 16th place can be inaccurate."""

#PythonTutorial #PythonDataTypes #NumericDataTypes #LearnPython #PythonForBeginners #PythonCoding #DataTypesInPython #PythonProgramming #CodingForBeginners #PythonSeries #python #coding #programming #datascience #learntocode #pythontips


Auf dieser Seite können Sie das Online-Video What is a Numeric Data Type in Python | EP-28 Numeric Data Types in Python | Python Data Types mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Cybrosys Technologies 19 August 2024 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 105 Mal angesehen und es wurde von 0 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!