Objectives


• To gain knowledge on the various fl ow of control in Python language. • To learn through the syntax how to use conditional construct to improve the effi ciency of the program fl ow. • To apply iteration structures to develop code to repeat the program segment for specifi c number of times or till the condition is satisfi ed.

Summary


- Programs consists of statements which are executed in sequence, to alter the flow we use control statements. • A program statement that causes a jump of control from one part of the program to another is called control structure or control statement. • Three types of flow of control are o Sequencing o Branching or Alternative o Iteration • In Python, branching is done using various forms of ‘if ’ structures. • Indentation plays a vital role in Python programming, it is the indentation that group statements no need to use {}. • Python Interpreter will throw error for all indentation errors. • To accept input at runtime, earlier versions of Python supported raw_input(), latest versions support input(). • print() supports the use of escape sequence to format the output to the user’s choice. • range() is used to supply a range of values in for loop. • break, continue, pass act as jump statements in Python. • pass statement is a null statement, it is generally used as a place holder.