- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python Numeric Types
The Numeric Types in Python are the integer datatypes. It includes integers, floatimg point, complex, etc. The complex includes real and imag parts. Also, includes Hexadecimal and Octal types.
Python int datatype
The Numeric Types include the int datatypes −
a = 5 print("Integer = ",a) print("Type = ",type(a))
Output
Integer = 5 Type = <class 'int'>
Python float datatype
The Numeric Types include the float datatypes −
Example
a = 7E2 print("Float = ",a) print("Type = ",type(a))
Output
Float = 700.0 Type = <class 'float'>
Python complex datatype
The Numeric Types include the complex datatypes with real and imaginary values −
Example
a = 2.75+3.15j print("Complex = ",a) print("Type = ",type(a))
Output
Complex = (2.75+3.15j) Type = <class 'complex'>
Python Hexadecimal Type
To represent Octal type (base 16), add a preceding 0x −
Example
a = 0x12 print("Hexadecimal = ",a) print("Type = ",type(a))
Output
Hexadecimal = 18 Type = <class 'int'>
Python Octal Type
To represent Octal type (base 8), add a preceding 0 (zero) −
a = 0O20 print("Octal = ",a) print("Type = ",type(a))
Output
Octal = 16 Type = <class 'int'>
- Related Articles
- List out the default values of numeric and non-numeric primitive data types in Java?
- Convert Long to numeric primitive data types in Java
- Convert Byte to numeric primitive data types in Java
- Convert Short to numeric primitive data types in Java
- Java Program to convert Double to numeric primitive data types
- Java Program to convert Java Float to Numeric Primitive Data Types
- Array — Efficient arrays of numeric values in Python
- Python Get the numeric prefix of given string
- Python – Split Numeric String into K digit integers
- Python Iterator Types
- Python Sequence Types
- Python Set Types
- Python Mapping Types
- Python Text Sequence Types
- Python Binary Sequence Types

Advertisements