THADOMAL SHAHANI ENGINEERING
COLLEGE
DEPARTMENT OF INFORMATION
TECHNOLOGY
[Link] making and control statements
Aim: Learning Control Statements in Python.
Theory:
• if Statement
The if statement is used to execute a block of code if a
specified condition is True.
• If-Else Statement
The else statement follows an if block and runs when the
condition in the if statement is False.
• Elif (Else If) Statement
elif allows you to check multiple conditions. It’s used
when you want to check more than one condition, and if
the first one fails, it checks the next one.
• Nested If Statements
You can also place an if statement inside another if
statement to check multiple conditions.
Program with output:
• WAP to calculate Factorial of a number given by user.
• WAP to display whether a number is Armstrong or not.
• Write a program to display prime numbers within a
range given by the user.
• WAP a program to display different patterns (Upper
and lower triangle, diamond, X).
UPPER AND LOWER TRIANGLE:
DIAMOND PATTERN
X PATTERN
• WAP a program to display table of a number given by user.
Conclusion:
We can observe the working of control statements in Python.