Lab 6.21.1

mail@pastecode.io avatar
unknown
python
2 years ago
860 B
2
Indexable
Never
# Defined your functions here.
binary_list = [] 
def int_to_reverse_binary(integer_value):
    bi = integer_value
    while integer_value > 0: 
        bi = int(integer_value % 2) 
        if(bi == 1) or (bi == 0):
            binary_list.append(bi)
            integer_value = integer_value // 2
    return binary_list
    
def string_reverse(input_string):
    reverse = binary_list[::-1]
    return reverse

if __name__ == '__main__':
    # Type your code here. 
    # Your code must call int_to_reverse_binary() to get 
    # the binary string of an integer in a reverse order.
    # Then call string_reverse() to reverse the string
    # returned from int_to_reverse_binary().
    int_put = int(input())
    int_to_reverse_binary(int_put)
    list_reverse = string_reverse(binary_list)
    for x in list_reverse:
        print(str(x), end='')
    print()