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
SCORPION-xisa [38]
2 years ago
14

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.
Computers and Technology
1 answer:
nexus9112 [7]2 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()

You might be interested in
Write a class named GasTank containing: An instance variable named amount of type double, initialized to 0. An instance variable
telo118 [61]

Answer:

The class GasTank is defined below

All the steps are briefed in comments

public class GasTank {

// instance variable initialization

private double amount = 0;

//declaring instance variable capacitance

private double capacity;

//constructor having parameter of type double

public GasTank(double i)

{

capacity = i;

}

// addGas method for increasing gas quantity.

public void addGas(double i)

//quantity of gas increased is added to the existing amount. If it becomes more than total capacity, amount is set to capacity

{ amount += i; if(amount > capacity) amount = capacity; / amount = amount < capacity ? amount+i : capacity;/ }

//useGas method having parameter of type double

public void useGas(double i)

//the parameter given is deducted from 0 and if results less than 0, remains equal to 0

{ amount = amount < 0 ? 0 : amount - i; }

//method isEmpty

public boolean isEmpty()

//Returns true if volume is less than 0.1 else false

{ return amount < 0.1 ? true : false; }

//method isFull

public boolean isFull()

//returns true if the value of amount is greater than  0.1 else false.

{ return amount > (capacity-0.1) ? true : false; }

//method getGasLeve

public double getGasLevel()

//Returns the value of amount instance variable

{ return amount; }

//method fillUp

public double fillUp()

//returns the difference between the capacity and the amount

{ double blah = capacity - amount; amount = capacity; return blah; }

}

5 0
3 years ago
Find prime no using Java
bonufazy [111]

Answer:

Um

Explanation:

I don't understand

4 0
3 years ago
On a web page coded in HTML, there is a sentence that reads, "Welcome to Assessments Section." Sam wants to insert the word "the
Natalka [10]

Answer:

The inserted text will appear as underlined text. The deleted text will appear as strike through text.

Explanation:

In HTML the text which has been inserted will appear as underlined text. It means if we insert something in HTML then it will underline it. This will highlight the text that has been inserted. While on the other hand if we delete some text and replace it with some other text, then it will appear as strikethrough text.

Strikethrough text is the text which is represented with a horizontal line in its center. It represents those words which are added by mistake and are not meant for inclusion.

7 0
3 years ago
The operation of early electronic computing devices required:
Harrizon [31]

Answer:

c

Explanation:

5 0
2 years ago
Consider the following statement, which is intended to create an ArrayList named a to store only elements of type Thing. Assume
bogdanovich [222]

Answer:

B: new ArrayList()

Explanation:

When dealing with Java syntax you always need to initialize an ArrayList object with its constructor. From the options listed the only correct option would be B: new ArrayList(). This would correctly initialize the ArrayList object but is not necessarily the recommended way of doing this. The truly recommended way would be the following

ArrayList<Thing> a = new ArrayList<Thing>()

7 0
2 years ago
Other questions:
  • On Gmail, can I have an email get sent to someone at a certain time?
    7·1 answer
  • Which of the following statements about the FAFSA process are TRUE?
    6·1 answer
  • Which command executed in Windows PE would transfer both the files and directory structure from one device to another device or
    6·1 answer
  • If a user copies the formula D15 into D16, what would the formula read in D16?
    15·2 answers
  • What nondestructive testing method requires little or no part preparation, is used to detect surface or near-surface defects in
    7·1 answer
  • What is active server page ?or why is it important?
    9·1 answer
  • CAD workstations
    11·1 answer
  • The purpose of a malfunction indicator lamp (MIL) is to:
    12·1 answer
  • Write out a shorthand version of the border property which will apply border that is 5 px wide, colored in lightgreen, and solid
    9·1 answer
  • The ______________ shows that you have fully researched the topic and gives you a chance to prove your claim.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!