hardMultiple ChoiceObjective-mapped
FC0-U71 Practice Question: A software developer is writing a script that…
A software developer is writing a script that needs to run a set of instructions repeatedly until a condition is met. Which programming construct should be used?
⚠ Common exam trap
Many exam-takers confuse a while loop with a for loop, mistakenly thinking a for loop can handle unknown iteration counts, but a for loop requires a predefined sequence or counter, while a while loop is designed for condition-based repetition.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
While loop
A while loop is the correct construct because it repeatedly executes a block of code as long as a specified condition remains true. This is ideal for scenarios where the number of iterations is not known in advance and depends on a dynamic condition, such as waiting for a file to appear or a network response.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
For loop
Why it's wrong here
For loop is best for iterating a known number of times.
- ✓
While loop
Why this is correct
While loop repeats as long as a condition is true.
- ✗
If-else statement
Why it's wrong here
If-else executes a block once based on a condition.
- ✗
Function definition
Why it's wrong here
A function defines a reusable block, not repetition.
Go deeper
Related to this question
About these practice questions
Courseiva writes every FC0-U71 question from scratch — 988 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
Same concept, more angles
3 more ways this is tested on FC0-U71
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. A programmer writes code to run a block of instructions repeatedly until a condition is met. Which programming concept is being used?
medium- A.Conditional
- ✓ B.Loop
- C.Function
- D.Variable
Why B: A loop (for, while) repeats code. Functions are reusable blocks, conditionals make decisions, variables store data.
Variation 2. A developer is writing a script in Python that processes user input. The script needs to execute a block of code repeatedly while a condition is true. Which programming construct should the developer use?
hard- A.for loop
- ✓ B.while loop
- C.function
- D.if/else
Why B: A while loop repeats a block of code as long as a condition is true.
Variation 3. A programmer is writing code that needs to repeat a block of instructions 10 times. Which programming construct is best suited for this task?
medium- A.Function
- B.Variable
- ✓ C.Loop
- D.Conditional (if/else)
Why C: A loop (such as a for loop or while loop) is designed to execute a block of code repeatedly, either a specified number of times or until a condition is met.
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This FC0-U71 practice question is part of Courseiva's free CompTIA certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the FC0-U71 exam.