''' CS5001 Fall 2018 Sample code: using a stack as the only data structure, convert an input decimal number to its binary equivalent. ''' from mystax import Stack def convert_to_binary(decimal): ''' Function convert_to_binary Input: decimal number (int) Returns: that decimal number in base 2 (string) ''' stack = Stack() if decimal == 0: return "0" while decimal >= 1: stack.push(decimal % 2) decimal = decimal // 2 result = "" while not stack.is_empty(): result = result + str(stack.top()) stack.pop() return result