menu

Python Control Structures

Python Control Structures - Important Points


1.

Which of the following is a control structure in Python?

A. Functions

B. Variables

C. Loops

D. Strings

Discuss Work Space

Answer: option c

Explanation:

Control structures are used to control the flow of execution in a program. Loops are one of the types of control structures in Python.


2. Which of the following is not a type of loop in Python?

A. for loop

B. while loop

C. do-while loop

D. nested loop

Discuss Work Space

Answer: option c

Explanation:

Python does not have a built-in do-while loop. However, you can simulate a do-while loop using a while loop.

3. Which loop executes a block of code a fixed number of times?

A. for loop

B. while loop

C. do-while loop

D. switch loop

Discuss Work Space

Answer: option a

Explanation:

The for loop is used to iterate over a sequence of items a fixed number of times.

4. Which loop executes a block of code as long as a specified condition is true?

A. for loop

B. while loop

C. do-while loop

D. switch loop

Discuss Work Space

Answer: option b

Explanation:

The while loop is used to execute a block of code repeatedly as long as a specified condition is true.

5. Which statement is used to exit a loop prematurely in Python?

A. break

B. continue

C. pass

D. exit

Discuss Work Space

Answer: option a

Explanation:

The break statement is used to exit a loop prematurely in Python.


Subscribe for Latest Career Trends
Subscribe Now
Use AI and ChatGPT for Career Guidance

Unlock Your Future

Join Now
Worried for Placements in 2024?

Join FAST TRACK Course

Join Now
Supercharge Your SUCCESS

Join All in One Placement Mock Tests-2024

Join Now