World's Best AI Learning Platform with profoundly Demanding Certification Programs
Designed by IITians, only for AI Learners.
Can any one help me in this 5-55 thing Que - Using for loop and range() 4)Print 5- 55 in steps of 10
This is using loops
Certainly! Here is one way to solve this problem using a for loop and the
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
10specifies the step size, so it will skip over numbers by increments of 10.
forloop 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 hope this helps! Let me know if you have any questions.
Running random forest algorithm with one variable