📖 generic · 12th TN - English Medium · COMPUTER SCIENCE · Page 73question

CONTROL STRUCTURES

Chapter 2: 3 · COMPUTER SCIENCE

CONTROL STRUCTURES 12th Computer Chapter - - There are three important control structures Sequential Alternative or Branching Iterative or Looping . . Sequential Statement A sequential statement is composed of a sequence of statements which are executed one after another. A code to print your name, address and phone number is an example of sequential statement.

# Program to print your name and address - example for sequential statement print ("Hello! This is Shyam") print (" , Second Lane, North Car Street, TN") Output Hello! This is Shyam , Second Lane, North Car Street, TN Example . .

. Alternative or Branching Statement In our day-to-day life we need to take various decisions and choose an alternate path to achieve our goal. May be we would have taken an alternate route to reach our destination when we find the usual road by which we travel is blocked. This type of decision making is what we are to learn through alternative or branching statement.

Checking whether the given number is positive or negative, even or odd can all be done using alternative or branching statement. Python provides the following types of alternative or branching statements: • Simple if statement • if..else statement • if..elif statement (i) Simple if statement Simple if is the simplest of all decision making statements. Condition should be in the form of relational or logical expression. 12th Computer Chapter - - Control Structures Syntax: if <condition>: statements-block1 In the above syntax if the condition is true statements - block will be executed.

# Program to check the age and print whether eligible for voting x=int (input("Enter your age :")) if x>= : print ("You are eligible for voting") Output : Enter your age : You are eligible for voting Output : Enter your age : >>> Example . As you can see in the second execution no output will be printed, only the Python prompt will be displayed because the program does not check the alternative process when the condition is failed. (ii) if..else statement The if .. else statement provides control

Related topics

Have a question about this topic?

Get an AI answer grounded in your actual textbook — with the exact page reference.

Ask AI about this topic →