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
spin [16.1K]
2 years ago
9

When do you use a for loop instead of a while loop? (There may be more than one answer.)

Computers and Technology
1 answer:
statuscvo [17]2 years ago
8 0

Answer:

- You know how many times you want the loop to run.

- When there is a defined start and end.

Explanation:

Required:

When to use for instead of while loop?

First, it should be noted that both for loop and while loop are used for iteration. However, depending on the scenario; there is preference on one to the other.

The basic syntax of for loop is:

for(start;end;condition)\{\}

<em>The condition could either be increment or decrement</em>

The basic syntax of while loop is:

while(condition)\{\}

<em>The condition could be any condition whatsoever</em>

Analyzing the options one after the other.

1. How many times the loop to run.

The for loop is preferred here because of the simplicity of the for loop.

2. & 3. Both the for and while loops are used for code repetition and to perform number calculations

4. Defined start and end.

From the syntax of the for loop

for(start;end;condition)\{\}

<em />

A for loop has a definite start and end in its basic syntax and is more preferable to use instead of a while loop.

<em />

<em />

Hence, 1 & 4 answer the question

You might be interested in
What is the output of the following?
lys-0071 [83]

Answer: a. the number is: 14

Explanation:

i mean just try to write in 7 instead of x in the second line

then it would say the number is: ....

what is 7 times 2?

14

so the answer is a

5 0
2 years ago
If we are using an 4-character password that contains only lowercase English alphabetic characters (26 different characters), ho
Trava [24]

Answer:

11,424,400 possible passwords

Explanation:

Since all characters are letters and only lowercase

we have 26∧4 = 456,976 possibilities

For a 5-character password which is still lower case sensitive.

we have 26∧5 = 11,881,376 possibilities

Many more possible passwords = (11881376-456976)

= 11,424,400 possible passwords

6 0
3 years ago
Read 2 more answers
Analytical processing uses multi-levelaggregates, instead of record level access.? True? False
Dominik [7]

Answer:

True.

Explanation:

Analytical processing uses multi-levelaggregates, instead of record level access.

8 0
3 years ago
What do you think about net neutrality??
Tomtit [17]
I think net neutrality should be kept! Removing net neutrality is unfair for all those who use the Internet! I think life would change is net neutrality did. Certain websites (a lot!) would slow down and cause a lot of people inconvenience, and I bet we'd have to pay more to use some sites!!!

NET NEUTRALITY SHOULD BE PRESERVED!!!!
6 0
3 years ago
Read 2 more answers
Write a function named replace_at_index that takes a string and an integer. The function should return a new string that is the
aalyn [17]

Answer:

def replace_at_index(str, number):

   new = str.replace(str[number], "-")

   return new

print(replace_at_index("eggplant", 3))

Explanation:

- Create a function called <em>replace_at_index</em> that takes a string and an integer

- Initialize a new variable called <em>new</em>, that will hold the new string

- Replace the character at given index with dash using <em>replace</em> function, it takes two parameters: the first is the character we want to replace, the second is the new character.

- Return the new string

- Call the function with the required inputs

4 0
3 years ago
Other questions:
  • I NEED IT FOR TODAY FOR KEYBOARDING TEST! GIVE ME CORRECT ANSWER PLZ!
    12·2 answers
  • 2.7 code practice question 1 edhesive
    13·2 answers
  • What steps might a company or organization need take in order to keep its digital data secure online?
    8·1 answer
  • Write down the characterizations that best suits the term Java applets?
    7·1 answer
  • You began a small mobile app company. To help market your apps, you create a social media site. The site allows users to join co
    15·1 answer
  • Select the correct answer from the drop-down menu.
    15·2 answers
  • EMERGENCY- I am giving 55 points for this, please help. WITH working out
    7·1 answer
  • Calculate how many different pixel colours could be formed if one of the bytes gives the intensity of the red colour, one of the
    15·1 answer
  • WHATS YALL FAVORITE GAME WHOEVER GIVES THE BEST ANSWER WINS 200
    13·2 answers
  • The best way to deal with crying children in the car is to ignore them or pull off the road
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!