What is a Loop?
In computer programming, a loop is a set of statements that are repeated until a certain condition is reached. The basic purpose of the loop is to repeat the same code according to our program requirements.
Python supports following two looping statements:
- while loop
- for loop
Python While Loop Programs
- Program to print 1 to 10 using while loop
- Program to print 10 to 1 using while loop
- Program to print Odd numbers between 1 to 10 using while loop
- Program to print sum of 1 to 100 (1+2+3+...+100)
- Sum of even numbers between 1 to 100 (2 + 4 + 6 + .... + 100)
- Sum of odd numbers between 1 to 100 (1 + 3 + 5 + ... + 99)
Python for Loop Programs
* * * * *
No comments:
Post a Comment