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
vladimir2022 [97]
3 years ago
11

The loop function is similar to range(), but handles the parameters somewhat differently: it takes in 3 parameters: the starting

point, the stopping point, and the increment step. When the starting point is greater than the stopping point, it forces the steps to be negative. When, instead, the starting point is less than the stopping point, it forces the step to be positive. Also, if the step is 0, it changes to 1 or -1. The result is returned as a one-line, space-separated string of numbers. For example, loop(11,2,3) should return 11 8 5 and loop(1,5,0) should return 1 2 3 4. Fill in the missing parts to make that happen.
Computers and Technology
2 answers:
Nady [450]3 years ago
5 0

Answer and Explanation:

def loop(start, stop, step):

   return_string = ""

   if step == 0:

       step = 1

   if start > stop:  # the bug was here, fixed it

       step = abs(step) * -1

   else:

       step = abs(step)

   for count in range(start, stop, step):

       return_string += str(count) + " "

   return return_string.strip()

omeli [17]3 years ago
5 0

Answer:

def loop(start, stop, step):

   return_string = ""

   if step == 0:

       step = 1

   if start > stop:

       step = abs(step) * -1

   else:

       step = abs(step)

   for j in range(start, stop, step):

       return_string += str(j) + " "

   return return_string

print(loop(11, 2, 3))

print(loop(1, 5, 0))

Explanation:

- Create a function called <em>loop</em> that takes three parameters: a starting point, a stopping point, and a step

- Initialize an array to hold the return values of the loop

- If the step equals 0, assign it to 1

- If the starting point is greater than the stopping point, take the absolute value of the step and multiply with -1

- If the starting point is not greater than the stopping point, take the absolute value of the step and multiply with 1

Until here you specified the starting point, stopping point and the step

- Create a for loop that iterates through starting point to the stopping point with the value of the step

- Add the numbers that are in the range to the return_string

- Return return_string

- Call the function to test the given scenarios

You might be interested in
En cual programa puedo hacer un mapa mental
mojhsa [17]
Hay aplicaciones especializadas para la creación de mapas mentales . Pero la herramienta más simple podría ser un papel y algunas plumas . El segundo sencillo cuando no tiene instalado el software podría ser la creación de un mapa mental en MS Word
3 0
3 years ago
The field of ____ is concerned with the technical issues involved in information display. computer science
Nataliya [291]

The field of <u>Computer graphics</u> is concerned with the technical issues involved in the information display. The correct option is A.

<h3>What is computer graphics?</h3>

Computer graphics is a branch of computer science called computer graphics research techniques for digitally synthesizing and modifying visual content.

Even while the phrase is frequently used to describe the study of three-dimensional computer graphics, it also includes image processing and two-dimensional graphics. This section works for information display.

Thus, the correct option is A. Computer graphics.

To learn more about computer graphics, refer to the link:

brainly.com/question/1169945

#SPJ4

The question is incomplete. Your most probably complete question is given below:

Computer graphics

computer-aided visualization

computer visualization

engineering graphics

7 0
2 years ago
How does my car radio know what song is playing?
Alexxandr [17]
It's probably like somebody that's copys it to the car like say the song is a good song (a drake song) it knows I guess or you told your company people to do that for you idrk
5 0
4 years ago
What is the purpose of an attribute in HTML
bearhunter [10]
Most of the HTML tags can also have attributes, which are extra bits of information
8 0
3 years ago
Read 2 more answers
If you wish to sign out of your Microsoft account, tap or click ____ on the ribbon to open the Backstage view and then tap or cl
lyudmila [28]
If you wish to sign out of your Microsoft account, tap or click file on the ribbon to open the Backstage view and then tap or click the Account tab to <span>display the Account gallery, and tap or click the Sign out link. There are different ways to do that but it is the easiest.</span>
7 0
3 years ago
Other questions:
  • PLS HELP ASAP! WILL GIVE BRAINLIEST!
    14·1 answer
  • What is the value of this expression?
    6·1 answer
  • Why would a brokered CD pay more than a regular CD?
    13·1 answer
  • Using a cell phone while operating a motor vehicle is considered distraction because
    8·1 answer
  • Without any formal planning, the president of a software company remarks in a speech that new technologically advanced software
    12·1 answer
  • You typed the word "weather" when you meant to type the word "whether." When will Writer or Word flag this as a misspelling or a
    6·2 answers
  • In the central processing unit (CPU).
    8·1 answer
  • Write a program that computes how much each person in a group needs to pay (after tax and tip) when splitting the bill equally.
    5·1 answer
  • Order the steps for changing the settings of an outlook data file
    10·1 answer
  • what statement about constructors is false? group of answer choices all constructors are passed a pointer argument constructors
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!