Write a Python program that asks for an integer n and then prints out the binary representation of that number.
Example 1:
Input: n = 5
Output: 101
Example 2:
Input: n = 8
Output: 1000
Use the divide by 2 method to find the binary representation of a number.
n = int(input("Enter a number: "))
binary = ''
while n > 0:
binary = str(n % 2) + binary
n = n // 2
print(binary)
NOTEOwing to browser caching, any code input into the Trinket IDE might carry over across page refreshes or when transitioning between different questions. To commence with a clean slate, either click on the 'Reset Button' found within the IDE's Hamburger icon (☰) menu or resort to using Chrome's Incognito Mode.