Answer:
# user is prompted to enter the value of n
n = int(input("Enter your number: "))
# if statement to check if n > 0
if (n > 0):
# for-loop to loop through the value of n
for digit in range(1, (n+1)):
# if digit is odd, print 1
if((digit % 2) == 1):
print("1", end=" ")
# else if digit is even print 0
else:
print("0", end=" ")
Explanation:
The code is written in Python and is well commented.
A sample output of the code execution is attached.