Skip to content
Menu
Code for Java c
  • Home
  • Java
    • Java Examples
    • Java tutorials
  • C
    • C tutorials
    • C Examples
  • C++
    • C++ Tutorials
    • C++ Examples
  • Python
    • Python Tutorials
    • Python Examples
  • About
    • About me
    • contact us
    • disclaimer
    • Privacy Policy
Code for Java c

Python language Numbers datatype

Posted on January 20, 2018January 11, 2020

Table of Contents

  • Python language numbers datatype
    • Number datatypes
    • Type conversion

Python language numbers datatype

In this tutorial, we will discuss the Python language Numbers datatype.

In every programming languages, they have many data types. In Python, data types are used to classify every particular type of data. The number is one of the data types used to store numeric values in Python.

Python supports four different numerical types

Number datatypes

Integer, long integer, floating-point and complex numbers are under the category number data type in python

  • int – int means the positive or negative whole number that never includes a decimal point. It is known as an integer. It is represented in a signed integer.

Eg –  5 – it is an integer, it has no decimal point

Python language Numbers datatype
Numbers datatype
 
Find the type of data
Python language Numbers datatype
Numbers datatype
When the above code is executed, The following output is displayed
Python language Numbers datatype
Numbers datatype

  • long  – long integers are an integer of infinitive size. This is similar to integer but followed by the letter “L”
Display long number
Find the type of data

 

  • float – floating-point of real values – float represents the real number, written with the decimal point

5.o – it is an float number, it has decimal point

Find the type of data

When the above code is executed, The following output is displayed

 

  • complex – complex number
  • Complx number is used to sciencific calculations
programmers can assign binary octal and hexadecimal numbers in python
if you want to assign this numbers you can use the following prefix on your number
Number SystemPrefix
Binary0b or 0B
Octal0o or 0O
Hexadecimal0x or 0X
Here are some example
Disp;ay python numbers
print(0b10011010);
#The output given The decimal value of binary number 10011010:
print(0xFD);
#The output given The decimal value of Hexadecimal number FD:
print(0o16);
#The output given The decimal value of octal number:

When the above code is executed, The following output is displayed

154
253
14

 

Calculate sum of python numbers

print(0b1101+0b1011)
#Find addition of two binary numbers
print(0xFB+0xA)
#Find addition of two hexadecimal numbers
print(0o5+0o4)
#Find addition of two Octal numbers

When the above code is executed, The following output is displayed

24
261
9

 

Type conversion

In python language, we can convert the type of number into another

We can use to convert some of built-in(predefined) function to type conversion of number data type such as int(), float(), complex()

 

 

Related Post

Data type in Python                                     List in Python       
Tuple in Python                                           Dictionary in Python                         
Set Data type in Python

 

 

Related

Recent Posts

  • Subtract two numbers using method overriding
  • PHP Star triangle Pattern program
  • Using function or method to Write temperature conversion : Fahrenheit into Celsius
  • Function or method:temperature conversion from Fahrenheit into Celsius – Entered by user
  • Write temperature conversion program: Fahrenheit into Celsius
  • How to write a program to convert Fahrenheit into Celsius

tag

Addition (6) Array (38) C++ language (91) C language (98) c sharp (23) Division (6) Function (29) if else (32) Java language (102) JavaScript (5) loops (137) Multiply (7) Oop (2) patterns (65) PHP (13) Python Language (38) Subtraction (7) temperature (20)

Archives

Categories

Address

Global information technology

Puloly south, PointPedro

Jaffna

Srilanka

©2025 Code for Java c | Powered by SuperbThemes