- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to Convert Decimal to Binary, Octal, and Hexadecimal using Python?
Python provides straightforward functions to convert Decimal to Binary, Octal, and Hexadecimal. These functions are −
Binary: bin() Octal: oct() Hexadecimal: hex()
You can use these functions as follows to get the corresponding representation −
decimal = 27 print(bin(decimal),"in binary.") print(oct(decimal),"in octal.") print(hex(decimal),"in hexadecimal.")
This will give the output −
0b11011 in binary. 0o33 in octal. 0x1b in hexadecimal.
- How to Convert Decimal to Octal?
- How to Convert Decimal to Hexadecimal?
- How to Convert Hexadecimal to Decimal?
- How to convert a Decimal to Octal using C#?
- How to Convert Binary to Octal?
- How to Convert Octal to Binary?
- How to Convert Binary to Hexadecimal?
- Python program to convert float decimal to octal number
- Java Program to convert Decimal to Octal
- How to Convert Decimal to Binary Using Recursion in Python?
- How to convert Decimal to Hexadecimal in Java
- How to convert Decimal to Binary using C#?
- Program to Convert Hexadecimal to Octal in C program
- Convert decimal integer to octal in Java