Question: In a base n number system, all numbers are written using only the digits {0,1,,n1}. For example, in the decimal (=base 10) number system that
In a base n number system, all numbers are written using only the digits {0,1,,n1}. For example, in the decimal (=base 10) number system that you are used to using, all numbers are written using the digits 0,1,,9, whereas in the binary (=base 2 ) number system, all numbers are written using the digits 0 and 1 only. Write a function basenum(num, base) that takes as arguments num (a non-negative integer) and base (a non-negative integer not greater than 10) and returns True if all digits of num are strictly less than base, and Fatse otherwise (using lazy evaluation). Once again, expect to be tripped up by one of the hidden test cases if you do not use lazy evaluation. For example: basenum (12345,8) True
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
