Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

PYTHON

CONTROL FLOW STATEMENTS


IN PYTHON
Part 02

K DAMITH GAYANTHA
Iteration/Loops
❑ In Python, we generally have two
loops/repetitive statements:

•while loop
•for loop
while loop

In Python, a statement that will be execute it is block of code, as long as


it is condition remain true.
Example 01
Examples

• Write a python program to get the total sum of


numbers from zero to 100
❑ Indefinite iteration

Example 02
Example 03

➢ When you run a program on the terminal and press Ctrl+c the default behavior is quit
the program.
❑ Whole not
Q1 .Write the python program to find the factorial of
a number ?
Q2.

• write a python program to get the sum and


average value that enters the marks obtained for
ten subjects.
Q3

• Write a python program to get the following output


Q4

Write a python program to find the factors of a


number
Q5

• Write a python program to find prime numbers using


if and while loop ?
Q6

• Write a Python program to find factors of a number


using while loop.
Thank you

You might also like