All Courses

Que - Using for loop and range() Print 5- 55 in steps of 10

By, 3 months ago
  • Bookmark

Can any one help me in this 5-55 thing Que - Using for loop and range()   4)Print 5- 55 in steps of 10

For loop
2 Answers

Hint :

This is using loops

stepping value 


Certainly! Here is one way to solve this problem using a for loop and the range() function:

for i in range(5, 56, 10):

This will print the numbers 5, 15, 25, 35, 45, and 55, each on a separate line.

Here's how this works:

  • range(5, 56, 10) generates a sequence of numbers starting at 5, and ending before 56 (that is, it will generate the numbers 5, 15, 25, 35, 45). The 10 specifies the step size, so it will skip over numbers by increments of 10.
  • The for loop will iterate over this sequence of numbers, and on each iteration, it will assign the value of the current number to the variable i, and then execute the indented code block. In this case, the code block is just a single line that prints i.

I hope this helps! Let me know if you have any questions.

Your Answer


How To Land a Job in Data Science?

Apr 6th (7:00 PM) 190 Registered
More webinars

Related Discussions

Running random forest algorithm with one variable

View More