Octal to Decimal conversion
Detailed guide and Python implementation for the 'Octal to Decimal conversion' problem.
Problem Statement
Write a function octal_to_decimal(octal_str) that takes a string representing an octal number (base-8, digits 0-7) and returns its decimal (base-10) integer equivalent.
Each digit in an octal number represents a power of 8, starting from the rightmost digit (8^0).
- •1 <= len(octal_str) <= 10
- •octal_str contains only digits '0' through '7'
Examples
octal_to_decimal('17')15
1×8¹ + 7×8⁰ = 8 + 7 = 15.
octal_to_decimal('144')100
1×8² + 4×8¹ + 4×8⁰ = 64 + 32 + 4 = 100.
octal_to_decimal('10')8
1×8¹ + 0×8⁰ = 8.
Need a Hint?
Edge Cases to Watch
- Empty input structures
- Single element inputs
- Large numerical bounds
Ready to Solve?
Open the problem in PyRun's browser-based Python editor. Your code runs fully offline — no server required.
Recommended Python Resources
Expand your knowledge with related interactive tutorials, cheat sheets, and code comparisons.
Python Generators
Learn how to use Python generators and yield statements to process huge datasets with minimal memory footprints. Master generator expressions.
How to Convert String to Int in Python
Learn how to convert a string to an integer in Python using the int() function. Handle errors safely and convert numbers from binary, octal, or hex.
Python Type Conversions
Learn implicit and explicit type conversions in Python. Convert between strings, integers, floats, lists, sets, and dictionaries.
Python Decorators vs Decorator Design Pattern: The Key Differences
Compare Python decorators and the classic decorator design pattern. Understand the differences between definition-time function wrapping and runtime dynamic object composition with runnable code.