Which of the following is a correct way to declare a for loop in python?

for i in range(1,5):

for i in range 1,2,3,4,5:

for i in range(5,1-1):

for i in range(1,5,1):

Correct Option - acd

The correct way to declare a for loop in Python is the Option 4:

scss
for i in range(1, 5, 1):

This creates a loop that starts at 1 and ends before 5, with a step of 1.

Therefore, the correct option is: Option 4 for i in range(1,5,1)

To get all Infosys Certified Python Associate Exam questions Join Group https://bit.ly/infy_premium_group

We're passionate about offering best placement materials and courses!! A one stop place for Placement Materials. We daily post Offcampus updates and Placement Materials.

Qtr No. 213, New Town Yehlanka Indore 454775

admin@prepflix.in