Question #300960

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


Expert's answer

'''
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", ""))




Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS