bulb states pattern
bulb states pattern program contain input is a single line containing a positive integer n representing the number of rooms in the building and the output should contain n lines , each line containing the state of the bulb in the room numbered from 1 to n in the form of 0 and 1.
example:
input: 5
'''
bulb states pattern
bulb states pattern program contain input is a single line containing
a positive integer n representing the number of rooms in the building
and the output should contain n lines , each line containing the state
of the bulb in the room numbered from 1 to n in the form of 0 and 1.
'''
n = int(input("Enter the no. of rooms: "))
if(n>0):
for r in range(1,n+1):
print("N =",r,":",bin(r).replace("0b", ""))
Comments
Leave a comment