StudyLover
  • Home
  • Study Zone
  • Profiles
  • Contact us
  • Sign in
StudyLover Octal Numbers
Download
  1. Python
  2. Text Processing with Python
Binary Numbers : Hexadecimal numbers
Text Processing with Python

Octal Numbers

Understanding Octal

Octal is a base-8 number system, which means it uses only eight digits (0-7) to represent numbers.

Representing Octal Numbers in Python

To represent an octal number in Python, you prefix it with 0o or 0O:

Python

octal_number = 0o75  # Equivalent to decimal 61

Converting Between Decimal and Octal

·         Decimal to Octal:

o    Use the oct() function:

Python

decimal_number = 61

octal_string = oct(decimal_number)  # Output: '0o75'

·         Octal to Decimal:

o    Use the int() function with base 8:

Python

octal_string = '0o75'

decimal_number = int(octal_string, 8)  # Output: 61

Key Points

·         Octal numbers are less commonly used than decimal or hexadecimal.

·         Python provides built-in functions for easy conversion between decimal and octal.

·         Octal numbers can be used for specific tasks, such as file permissions in Unix-like systems.

 

Binary Numbers Hexadecimal numbers
Our Products & Services
  • Home
Connect with us
  • Contact us
  • +91 82955 87844
  • Rk6yadav@gmail.com

StudyLover - About us

The Best knowledge for Best people.

Copyright © StudyLover
Powered by Odoo - Create a free website