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
Sean is studying at a friend's house and notices that he can connect to the wireless network without entering a wireless network
polet [3.4K]
It is a personal network of Sean’s friends family’s
5 0
3 years ago
A database on a mobile device containing bands, sub-bands and service provider IDs allowing the device to establish connection w
VashaNatasha [74]

Answer:

A. PRL

Explanation:

Mobile phone technologies like CDMA , GSM etc, are used by cell/ mobile phone to transmit and receive signals. With the limitation of fluctuation, a mobile phone was made to adapt to this problems, thereby combining this broadbands like CDMA, GSM,4G LTE etc gave rise to PRL (Preferred roaming list) database to hold information needed to establish connection to the correct cell tower for these broadbands.

3 0
4 years ago
What happens to the files and folders on the desktop when the computer is turn off
andriy [413]

Answer:

All of the files are stored on a hard-drive. Except for the files you just viewed before turning off the computer, which is stored in the RAM (Random Access Memory). If your computer is a desktop, and the power goes out while looking at a photo/pdf, you may corrupt/lose the image if the computer didn't have enough time to store it in the hard drive. Everything in the hard drive is 'scratched' into it like a record. If you delete a file, that part of the disk is 'smoothed' as best as it can. If you upload another file, you might corrupt/ruin the image/pdf. Think of the smoothing like recording a football game over an old VHS of Winne the Pooh. If you have any other questions, please ask by commenting on this answer!

4 0
3 years ago
The cost of a given amount of computing power has _____.
lana [24]

Answer:

decreased drastically over the last five decades

Explanation:

I would say it is that answer because a few decades ago we needed huuuge computers that filled rooms to compute simple tasks. Now we have cellphones, which are basically computers that can fit into the palm of our hands. Our phones can do more than what those huge computers of the past did and they're easier to produce. So cost must have drastically decreased.

3 0
3 years ago
Read 2 more answers
Why should you delete files from your computer
notka56 [123]

deleting files can free up space and prevent hackers from accessing your sensitive files

5 0
2 years ago
Read 2 more answers
Other questions:
  • Create short names for the terms below based on the naming conventions rules.
    14·1 answer
  • What specific information would you need to obtain from an ISP or cloud service provider whose hosting services you wanted to us
    9·1 answer
  • A(n) ____ is a system designed to handle only very basic applications with an absolute minimum amount of hardware required by th
    9·1 answer
  • Suppose in a class of 100 students, there is a homework due every week. The professor wants to encourage students to hand in the
    8·1 answer
  • You want to average the numbers in the range b1:b30. you have named this range of cells data and wish to use this range name in
    9·1 answer
  • . Find four different commands in Internet Explorer and identify their keyboard shortcuts. A. B. C. D.
    10·1 answer
  • Write a program with total change amount as an integer input that outputs the change using the fewest coins, one coin type per l
    15·1 answer
  • In the movie, Willy Wonka and the Chocolate Factory, Augustus Gloop leans over the chocolate river to get a drink and falls in.
    11·1 answer
  • E-What is the important of Recycle bin?<br>Ans:​
    12·1 answer
  • In your own words discuss 4 major strength and weakness<br> of<br> computer
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!