2. Loops
• The for loop is of the following form.
• The range indicates the number of times a statement will be implemented.
• There is a colon value to indicate the start of for loop.
• The code below is executed many times. The number of times it gets
executed depends on the values specified in range.
• Note that the code below the for statement is indented.
3. Loops
• The for loop is of the following form.
• Try different values inside the brackets of range
4. Loops
• The for loop is of the following form.
• Try different values inside the brackets of range
• Note that everything with indentation below for loop is executed as a
part of the loop.
9. Combine loops and conditionals
1. Write a program to print even numbers
2. Write a program to print the factorial of a number. Factorial of a
number is: N x (N-1) x (N-2) x .. x 1
• Example: factorial of 4 is represented by 4! = 4x3x2x1
• 10! = 10x9x8x7x6x5x4x3x2x1