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
mixer [17]
3 years ago
11

When do you use a while loop instead of a for loop? (Select multiple answers)

Computers and Technology
1 answer:
Alla [95]3 years ago
7 0

Answer:

1. You do not know how many times a loop will need to run

4. To repeat code.

Explanation:

Required

When to use while loop instead of for loop?

Option 1 and 4 answer the question

<em>1. You do not know how many times a loop will need to run </em>

Using while loop in this case is suitable to the for loop.

Take for instance

You want a set of instruction to be repeated until the user enters 1

e.g.

<em>while a != 1:</em>

<em>     print("abc")</em>

<em>     print("def")</em>

<em>     a = int(input("Input: "))</em>

<em />

The above is written in Python

The print instructions will be repeated until the user enter 1.

Now, you do not know if the user will enter 1 the first time or the 100th time or the 10000th time.

In other words, you don't know how many times the loop will be executed.

In this case, while loop is preferred to for loop

4. To repeat code:

The same analysis as used in (1) above is applicable in (4).

The print statements in

<em>while a != 1:</em>

<em>     print("abc")</em>

<em>     print("def")</em>

<em>     a = int(input("Input: "))</em>

will be repeated until the user enters 1

The for loop isn't preferable in this case

<em>Other options (2) and (3) can be implemented using both the for loops and the while loops</em>

You might be interested in
Which is the last step in conducting a URL search?
m_a_m_a [10]
It all depends what you are looking for...
3 0
3 years ago
Read 2 more answers
Which statement is true of Web-based social media?
Nataliya [291]
I think the answer is A.
6 0
3 years ago
PLEASEEE HELPPPP me
insens350 [35]

Answer:

D

Hope This Helps!   Have A Nice Day!!

7 0
3 years ago
What type of font color should Kim select if she chooses a dark-colored design theme for her presentation?
Gnesinka [82]

ANSWER: Kim has chosen a dark-colored design theme for her presentation. She should therefore choose <u>a bright </u> font color that will <u>contrast with  </u>the background color.

5 0
4 years ago
Read 2 more answers
I will give brainyest
Trava [24]

Answer:

Power down your Chromebook by doing a hard reset.

Explanation:

The first thing to check for when your Chromebook won't turn on is a dead battery. Plug the unit in via AC charger and let it charge for at least 30 min to an hour and try turning it on again.

3 0
2 years ago
Read 2 more answers
Other questions:
  • In the database below, the arrow is pointing to a _____.<br> file<br> record<br> field<br> key field
    12·1 answer
  • ________ are found on the motherboard and are used to attach your hard disk.
    6·1 answer
  • One group of students did an experiment to study the movement of ocean water. The steps of the experiment are listed below.
    10·1 answer
  • Componets of computer
    5·1 answer
  • When a bank account pays compound interest, it pays interest not only on the principal amount that was deposited into the accoun
    10·1 answer
  • Which of the following statements are true?
    13·1 answer
  • A _____ are devices that permit a user to connect to a digital t-carrier service.
    6·1 answer
  • Explain how SEO impacts the way you should interpret search engine results ???
    6·1 answer
  • Which similar computer network components connect multiple devices?
    7·1 answer
  • besides entering a url to go directly to a website, what else can you enter in a browser address bar to explore the internet?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!