Saturday, 1 September 2018

Python Numbers


Python Numbers
There are three numeric types in Python:
  • int
  • float
  • complex
Variables of numeric types are created when you assign a value to them:

Example
x = 111     # int
y = 23.878  # float
z = 1j      # complex

To verify the type of any object in Python, use the type() function:

Example
print(type(x))
print(type(y))
print(type(z))

output:-
<class'int'>                                     
<class'float'>                                   
<class 'complex'>

No comments:

Post a Comment

Lists

Python  Lists Python Collections (Arrays) There are four collection data types in the Python programming language: List  is a ...