Programming with Python

⌘K
  1. Home
  2. Docs
  3. Programming with Python
  4. Introduction to Python
  5. Values and Types
  6. Numeric Data Type

Numeric Data Type

  • Numeric data type represent the data which has numeric value
  • Numerical Data type is immutable i.e. the value cannot be changed
  • Numeric value can be Integer, floating number or even complex numbers
  • These values are defined as int, float and complex class in python

Integers

  • This value is represented by int class
  • It contains positive or negative whole numbers (without fraction or decimal)
  • In python, there is no limit to how long an integer value can be

Example

>>> x=1
>>> print(type(x))
<class 'int'>

Float

Example

>>> y=3.14
>>> print(type(y))
<class 'float'>

Complex

  • Complex number is represented by complex class
  • It is specified as a+j b
    • Where a is real part and b is imaginary part

Example 4+2j

>>> z = 3+ 2j
>>> print(type(z))
<class 'complex'>
  • type( ) function is used to determine the type of data type

Loading

Views: 14

How can we help?

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments