All Courses

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

By Sde221876@gmail.com, 3 months ago
  • Bookmark
0

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
Range
Functions
Python
2 Answers
0
Hitendradixit18@gmail.com

Hint :

This is using loops

stepping value 

0
Goutamp777

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

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

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

Webinars

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