Python BasicsEasy

Octal to Decimal conversion

Detailed guide and Python implementation for the 'Octal to Decimal conversion' problem.

Problem Statement

Easy

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).

Constraints
  • 1 <= len(octal_str) <= 10
  • octal_str contains only digits '0' through '7'

Examples

Example 1
Input
octal_to_decimal('17')
Output
15
Explanation

1×8¹ + 7×8⁰ = 8 + 7 = 15.

Example 2
Input
octal_to_decimal('144')
Output
100
Explanation

1×8² + 4×8¹ + 4×8⁰ = 64 + 32 + 4 = 100.

Example 3
Input
octal_to_decimal('10')
Output
8
Explanation

1×8¹ + 0×8⁰ = 8.

Need a Hint?
Consider using Numbers-specific data structures like sets or heaps.
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.

Open in Editor

Recommended Python Resources

Expand your knowledge with related interactive tutorials, cheat sheets, and code comparisons.