Examveda

What is the main purpose of a loop in Python?

A. To write comments

B. To execute code only once

C. To repeat a block of code

D. To define functions

Answer: Option C

Solution (By Examveda Team)

The main purpose of a loop in Python is to repeat a block of code.
Loops are fundamental control structures in programming languages that allow the execution of a certain block of code repeatedly. In Python, loops such as for loops and while loops enable you to iterate over sequences, perform operations on elements, and execute code multiple times based on specified conditions. This capability is essential for automating repetitive tasks, processing large amounts of data, and implementing algorithms that require repeated execution of certain steps.

This Question Belongs to Python Program >> Introduction To Python

Join The Discussion

Related Questions on Introduction to Python