1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
vlada-n [284]
3 years ago
10

Consider the series of alternating 1s and 0s 1 0 1 0 1 0 1 0 1 0 ...... The user will enter a number n . And you have to output

the first n numbers of this sequence (separated by spaces) You may assume the user will enter n > 0 and an integer using two if statements

Computers and Technology
1 answer:
Vika [28.1K]3 years ago
8 0

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.

You might be interested in
what is the gpa(grade point average) you need to have or you get kicked out of robotics for middle school?
Mama L [17]
It depends on the school. At my school anyone can be in robotics club.
3 0
3 years ago
Read 2 more answers
Which of the following are incorrect safety precautions for equipment operators? A. Drive equipment or vehicles on grades or roa
Zarrin [17]
Hello!

The correct answer would be: D. Should not exceed a vehicle's rated load or life capacity.

I hope you found this helpful! :)
3 0
3 years ago
Read 2 more answers
Please help with attached file
Paul [167]
Where is the attached file?
8 0
3 years ago
Read 2 more answers
PLEASE HELP SOMEONE!!!!!!!!! WILL GIVE BRAINLIEST!!!!!!!!!!!!!!!!!!!!!!!!! Fill in the blanks.
olasank [31]
<span> change the behavior of the program I think</span>
7 0
4 years ago
What are some examples of environmental technology
Zarrin [17]
Some examples of environmental technology is recycling.
3 0
3 years ago
Other questions:
  • True or false the primary advantage of the worksheet is the ability to solve numerical problems quickly and accurately
    11·1 answer
  • What is a device driver?
    9·2 answers
  • What considerations have to be kept in mind with JPEG
    10·1 answer
  • ​if a primary key combines two or more fields, then it is called a _____.
    14·1 answer
  • Who is the founder of javascript? ​
    14·2 answers
  • Brainly wont show me the "I'm Done" button after an interactive ad, and I cant figure out why. I've watched the entire ad, click
    11·2 answers
  • We have three containers whose sizes are 10 pints, 7 pints, and 4 pints, respectively. The 7-pint and 4-pint containers start ou
    14·2 answers
  • Write a program to enter a number and test if it is greater than 45.6. If the number entered is greater than 45.6, the program n
    10·1 answer
  • Can someone start me off with a short 2 or 3 paragraphs about the pros and cons of Microsoft Word, and if you can recommend a si
    12·1 answer
  • Explain how to utilize the computer in rooms management.​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!