Page 36 - 2501_KVS_C-8
P. 36
2.4 SEQUENCE BASED PROGRAMMING
You have already learnt about simple programming in Python in class VII. Here, it is once
again is discussed for revision and more clarity. As we know that programming is the
execution of some commands in an order. This is termed as sequential programming. Let us
understand and revise it with a simple example.
Suppose, we have to make a program in Python in which we have to accept the “Age” of a
person from the user and display its age on the screen after 5 years. Let us write the code
for the same in python as given below:
age=int(input("Enter your Age:-"))
print("You have entered age : ",age)
print("Your age after 5 years will be : ",age+5)
Now, you may observe the commands in python for the above said program. Also, we will see
its output at run-time which is given below:
Enter your Age:-14
You have entered age : 14
Your age after 5 years will be : 19
As you may observe that above three (03) commands are executed in the order in which
they are written and one cannot change the order of execution. So, this is understood as
Sequence based programming.
There are a few examples given for more practice at the end of this unit.
2.5 ‘IF...ELSE’ STATEMENT
In python, if…else statement is used to test/check one or more condition(s) and then
execute some commands. The if…else statement evaluates test expression and will execute
the body of if only when the test condition is True. If the condition is False, the body of
else is executed. Statements that are written at the same indent form a block.
The SYNTAX of if..else statement is:
if <condition>:
Statement 1
Statement 2
…
…
Statement N
else:
Statement 1
Statement 2
…
…
Statement N
34 KVS DELHI REGION 2025

