Generation

generate functionThu, 22 Dec 2022

Given a non-negative integer n, write a function to_binary/ToBinary which returns that number in a binary format. to_binary(1) # should return 1 to_binary(5) # should return 101 to_binary(11) # should return 1011

def to_binary(n): return bin(n)

Questions about programming?Chat with your personal AI assistant