For loops in Python are used to iterate over a sequence. Some examples include:
1) Printing a school name 5 times using a for loop with a range of 5.
2) Printing each character of the text "hello world" on a new line using a for loop to iterate over the string.
3) Printing the natural numbers from 10 to 1 in reverse order using a for loop with a range of 10 to 1 and an increment of -1.
4) Printing the first 10 even numbers using a for loop with a range of 10 and an increment of +2.
For loops in Python are used to iterate over a sequence. Some examples include:
1) Printing a school name 5 times using a for loop with a range of 5.
2) Printing each character of the text "hello world" on a new line using a for loop to iterate over the string.
3) Printing the natural numbers from 10 to 1 in reverse order using a for loop with a range of 10 to 1 and an increment of -1.
4) Printing the first 10 even numbers using a for loop with a range of 10 and an increment of +2.
For loops in Python are used to iterate over a sequence. Some examples include:
1) Printing a school name 5 times using a for loop with a range of 5.
2) Printing each character of the text "hello world" on a new line using a for loop to iterate over the string.
3) Printing the natural numbers from 10 to 1 in reverse order using a for loop with a range of 10 to 1 and an increment of -1.
4) Printing the first 10 even numbers using a for loop with a range of 10 and an increment of +2.
UNDERSTAND THE NOTES (0:00 – 11:30 ONLY) (CLICK CROW GAWAARO)
WAP using for loop to print your
school’s name five times. For and in are keywords x is variable it is printed 5 times by putting the range as 5 as the loop works from 0 to 5.
WAP using for loop to print each
alphabet of the text “hello world” in separate lines. WAP using for loop to print the natural numbers from 10 to 1 in reverse order. We have to put -1 because python takes +1 as default increment. We have to change this default increment. So, it goes from 10 to 1, each reducing 1(-1).
WAP using for loop to print the first 10
even number. The default increment is changed from +1 to +2 for printing even numbers.