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
You have the templates of 2 classes, Person and Program. The Person class has 4 attributes, name, age, major and gpa. There is a
Ostrovityanka [42]

Answer:

Hi, I'm going to put the code answer here and you put in the corresponding line to not copy all the code in the answer.

replace the following line or adjust to the following code

/*

* CODE HERE

while(personSelect <= 0 || personSelect  > 5) {

System.out.println("Wrong number, try to input the number in range 1 to 5" );

personSelect = scan.nextInt();

}

if(personSelect == 1){

person1.setGpa(newGPA);

printInfo()

}

else if(personSelect == 2){

person2.setGpa(newGPA);

printInfo()

}

else if(personSelect == 3){

person3.setGpa(newGPA);

printInfo()

}

else if(personSelect == 4){

person4.setGpa(newGPA);

printInfo()

}

else {

person5.setGpa(newGPA);

printInfo()

}

*/

Explanation:

According to the description of code, we have to add some lines to resolve the questions.

a):

In base on the input, we have to modify the <em>attribute GPA</em> with the method <em>setGpa</em> depending on the person chosing. We call the person chosen before and also call the method setGpa( ) and pass  as <em>parameter</em> the GPA value obtained in tha last input

b)

In this case we have to <em>create a loop</em> for iterate the times that is necesary to get a value of person that is permit in <em>range 1 to 5</em>, and hence that we create and individual if condition to assign the GPA to the person chosen.

I hope it's help you.

8 0
3 years ago
Assume that success is a variable of type boolean that has been declared. Assume that processor refers to an object that provide
Iteru [2.4K]
Try {
AutoFactory.shutdown();
} catch (ProductionInProgressException e) {
AutoFactory.reset();
}
6 0
2 years ago
Before you ever buy your first stock or bond, it's important to understand what type of investor you are. This depends on a numb
Oksi-84 [34.3K]

Answer:

Moderate investor

Explanation:

The moderate investors are most popularly known as 'Balanced investors'. They accepts the risk to principal and they adopt the balanced approach. They mainly uses a mixture of bonds and stocks.

They values the reducing risks and then enhancing the returns equally. They accepts modest risks so as to ensure higher long term returns.

6 0
2 years ago
The view that perceptual processes take place over time and can be thought of in terms of a software/hardware metaphor is known
Wittaler [7]

The view that perpetual processes can be thought of in terms of a software/hardware metaphor is known as the: information processing view.

<h3>What is the Information Processing View?</h3>

Information processing view is explained by the cognitive theory to explain how the brain encodes information and how information are filtered from what we pay attention to in a particular moment. This also determines what is stored in the short-term or in our long-term memory.

Therefore, the view that perpetual processes can be thought of in terms of a software/hardware metaphor is known as the: information processing view.

Learn more about the information processing view on:

brainly.com/question/24863946

3 0
2 years ago
How do medical detectives investigate their cases?
tensa zangetsu [6.8K]

Answer:

Analyze genetic testing results to diagnose disease and study DNA evidence found at a “crime scene.” They solve medical mysteries through hands-on projects and labs, investigate how to measure and interpret vital signs, and learn how the systems of the human body work together to maintain health.

Explanation:

I answered it under the wrong part but this is same thing i put before.

4 0
3 years ago
Read 2 more answers
Other questions:
  • Which task might be suitable for moving into a separate function so you can re-use it from multiple places in your code?
    11·1 answer
  • Chdtp aoxophg gr72 ae9&gt;3 zqqz
    12·1 answer
  • A patient presents at an outpatient urgent care facility with an acute illness and is seen by a provider. A detailed history wit
    13·1 answer
  • Review the two e-mail messages below for their adherence to the guidelines for professional e-mail correspondence you have learn
    6·1 answer
  • One of the driving forces in operating system evolution is advancement in the underlying hardware technology.
    8·1 answer
  • A Computer Programmer who wants to be surrounded by a large number of like-minded coworkers should take a job with one of the na
    14·2 answers
  • Do you think lossy compression formats will be popular in 20 years? Why or why not?
    10·1 answer
  • Different between input and output device​
    5·1 answer
  • Design the following webpage using suitable html code .
    11·2 answers
  • If you want to join all of the rows in the first table of a SELECT statement with just the matched rows in a second table, you u
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!