[go: up one dir, main page]

0% found this document useful (0 votes)
8 views3 pages

Int Data Type

The document explains the 'int' data type in Python, which is used to store integral or whole numbers. It covers different number systems including decimal, binary, octal, and hexadecimal, detailing how each can be represented in Python with specific prefixes. Examples illustrate the usage of these number systems and their conversion to decimal values during execution.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

Int Data Type

The document explains the 'int' data type in Python, which is used to store integral or whole numbers. It covers different number systems including decimal, binary, octal, and hexadecimal, detailing how each can be represented in Python with specific prefixes. Examples illustrate the usage of these number systems and their conversion to decimal values during execution.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

========================================================

1. int
=========================================================
=>Here 'int' is one of the Pre-defined Class and Treated as Fundamental Category
Data Type.
=>The purpose of Int Data type is that "To store Integral OR Whole Numbers OR
Integer Values".
---------------------------
Examples
--------------------------------- -----------------------------------------
---
Python Instructions output
-------------------------------- -----------------------------------------
---
>>> a=10
>>> print(a)-------------------------------------------10
>>> type(a)-------------------------------------------<class 'int'>
>>> id(a)-----------------------------------------------140722796504264
>>> print(a,type(a),id(a))--------------------------10 <class 'int'>
140722796504264
----------------------------------
>>> a=10
>>> b=20
>>> c=a+b
>>> print(a,type(a),id(a))-------------------------10 <class 'int'> 140722796504264
>>> print(b,type(b),id(b))-------------------------20 <class 'int'> 140722796504584
>>> print(c,type(c),id(c))--------------------------30 <class 'int'>
140722796504904
-----------------------------------------------------------------------------------
---------------------------------------------------
=>In Python Programming, By using 'int' Data type, we can also Store Different
Number System Values.
=>In Any Programming Lang, we have 4 Types of Number Systems. They are
1. Decimal Number System
2. Binary Number System
3. Octal Number System
4. Hexa Decimal Number System
-----------------------------------------------------------------------------------
-----------------------------------------
1. Decimal Number System
-----------------------------------------------------------------------------------
-----------------------------------------
=>The Decimal Number System is the Default Number System used by all Human Beings
for Day-to-Day Calculations.
=>The Decimal Number System contains the following
Digits : 0 1 2 3 4 5 6 7 8 9 ------------- Total:
10
Base : 10
=>All Base 10 Literals are called Decimal Number System Values.
-----------------------------------------------------------------------------------
-----------------------------------------
2. Binary Number System
-----------------------------------------------------------------------------------
-----------------------------------------
=>The Binary Number System is Unstandable by OS and Processor during Program
Execution.
=>The Binary Number System contains the following
Digits: 0 1 -------------Total : 2
Base : 2
=>Hence Base 2 Literals Binary Number System Values.
=>In Python Programming, Binary Number System Values can be store / Represented
by Preceding with a Letter Called '0b' OR '0B'.
=>Syntax: varname=0b Binary Data
OR
varname=0B Binary Data
=>Even though we store the Binary Data in Python Program, Python Programming
execution envronment automatically converts into Decimal Number System bcoz python
is one of the High Level Lang.
-----------------------------
Examples
------------------------------
>>> a=0b1001
>>> print(a,type(a))-------------------------9 <class 'int'>
>>> a=0B1111
>>> print(a,type(a))------------------------15 <class 'int'>
>>> a=0B10000
>>> print(a,type(a))-----------------------16 <class 'int'>
>>> b=0b1002------------------------------SyntaxError: invalid digit '2' in binary
literal
-------------------------
>>> bin(9)-----------------------------'0b1001'
>>> bin(15)---------------------------'0b1111'
>>> bin(16)---------------------------'0b10000'
-----------------------------------------------------------------------------------
-----------------------------------------
3. Octal Number System
-----------------------------------------------------------------------------------
-----------------------------------------
=>The Octal Number System is Unstandable by 8086 Micro Processor / Aseembly
Language Programming during
Program Execution.
=>The Octal Number System contains the following
Digits: 0 1 2 3 4 5 6 7 -------------Total : 8
Base : 8
=>Hence Base 8 Literals Octal Number System Values.
=>In Python Programming, Octal Number System Values can be stored / Represented
by Preceding with a Letter Called '0o' OR '0O'.
=>Syntax: varname=0o Octal Data
OR
varname=0O Octal Data
=>Even though we store the Octal Data in Python Program, Python Programming
execution envronment automatically converts into Decimal Number System bcoz python
is one of the High Level Lang.
-------------------------------
Examples
-------------------------------
>>> a=0o17
>>> print(a,type(a))--------------------------------15 <class 'int'>
>>> a=0O14
>>> print(a,type(a))--------------------------------12 <class 'int'>
>>> a=0O123
>>> print(a,type(a))--------------------------------83 <class 'int'>
>>> a=0o18------------------------------------------SyntaxError: invalid digit '8'
in octal literal
-----------------------------------------------------------------------------------
-----------------------------------------
4. Hexa Decimal Number System
-----------------------------------------------------------------------------------
-----------------------------------------
=>The Hexa Decimal Number System is used Development of OS Level Applications.
=>The Hexa Decimal Number System Contains the following
Digits: 0 1 2 3 4 5 6 7 8 9
A or a(10), B or b(11) , C or c(12) , D or
d(13), E or e(14), F or f(15)-----Total :16
Base : 16
=>All Base 16 Literals are called Hexa Decimal Number System Values.
=>In Python Programming, Hexa Decimal Number System Values can be stored /
Represented by Preceding with a Letter Called '0x' OR '0X'.
=>Syntax: varname=0x Hexa Decimal Data
OR
varname=0X Hexa Decimal Data
=>Even though we store the Hexa Decimal Data in Python Program, Python Programming
execution envronment automatically converts into Decimal Number System bcoz python
is one of the High Level Lang.
------------------------------
Examples
------------------------------
>>> a=0xAC
>>> print(a,type(a))-----------------172 <class 'int'>
>>> a=0XBEE
>>> print(a,type(a))-----------------3054 <class 'int'>
>>> a=0XFace
>>> print(a,type(a))----------------64206 <class 'int'>
>>> a=0XFacer----------------------SyntaxError: invalid hexadecimal literal
>>> a=0x1B
>>> print(a,type(a))---------------27 <class 'int'>

-----------------------------------------------------------------------------------
-------------------------------------------------------------------------

You might also like