python int()class - Binary-Octal-Hexadecimal-Decimal also integer Datatypes

#store integer using int() class

#variable declaration with value assigning using int() class or contractor 

empid = int(25)

print(empid)  

print(type(empid))  

output : 25

<class : int>


You can also store integer values other than base 10 such as

Binary (base 2- 0,1)

Octal (base 8 - 0,1,2,3,4,5,6,7)

Hexadecimal numbers (base 16 - 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F)

Decimal(10 - 0,1,2,3,4,5,6,7,8,9)

Octal :

octnum=0o10

print(octnum)

print(type(octnum))

output:

8

<class 'int'>

Hexadecimal Numbers : 

hexanum=0x10

print(hexanum)

print(type(hexanum))

Output:

16

<class 'int'>

Binary:
binanum=0b10
print(binanum)
print(type(binanum))

Output:
2
<class 'int'>



No comments:

Post a Comment

Latest Post

How to Generate Barcode and QR code For Our Products

 మీ products కి barcode / QR code generate చేయాలంటే OPTION 1: ONLINE (No Coding – Quick) Best for small shops / beginners 👉Free websites: T...