Question: Question # 2 : to _ decimal ( oct _ num ) 1 0 pts Given a number oct _ num in octal system (

Question #2: to_decimal(oct_num)10 pts
Given a number oct_num in octal system (base 8), return oct_num in decimal system (base 10). In
the octal number system, each digit represents a power of eight and it uses the digits 1 to 7. To
convert a number represented in octal system to a number represented in decimal system, each
digit must be multiplied by the appropriate power of eight. For example, given the octal number
2068 results in the decimal number 13410:
206
828180
You are NOT allowed to type convert num to a string , use lists in any form, add
the digits into a list to traverse or process the number, or to use of the math module
Preconditions and Postconditions
oct_num: int -> Positive number that always starts with a digit in range 1-7
Returns: int -> decimal representation of oct_num
Example:
>>> to_decimal(237) # (82*2)+(81*3)+

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!