figure decimal-to-binary conversion creates an empty string the binary digits are popped from the stack one at time and appended to the right-hand end of the string the binary string is then returned import stack as previously defined def divide_by_ (dec_number)rem_stack stack( while dec_number rem dec_number rem_stack push(remdec_number dec_number / bin_string "while not rem_stack is_empty()bin_string bin_string str(rem_stack pop() return bin_string print(divide_by_ ( )he algorithm for binary conversion can easily be extended to perform the conversion for any base in computer science it is common to use number of different encodings the most common of these are binaryoctal (base )and hexadecimal (base the decimal number and its corresponding octal and hexadecimal equivalents and are interpreted as and the function divide_by_ can be modified to accept not only decimal value but also base for the intended conversion the "divide by idea is simply replaced with more general "divide by base new function called base_convertershown belowtakes decimal number and any base between and as parameters the remainders are still pushed onto the stack until the value being converted becomes the same left-to-right string construction technique can be used with one slight change base through base basic data structures