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

CONTROL STRUCTURES · Part 8

Chapter 2: 3 · COMPUTER SCIENCE

(end='\n') i += Example . : program to illustrate the use nested loop -for within while loop Output: . . Jump Statements in Python The jump statement in Python, is used to unconditionally transfer the control from one part of the program to another.

There are three keywords to achieve jump statements in Python : break, continue, pass. The following flowchart illustrates the use of break and continue. Condition Further Statements of Program else Statement Statement ... Statement n False True Statement ...

break ... continue ... Statement n Fig . Use of break, continue statement in loop structure 12th Computer Chapter - - Control Structures (i) break statement The break statement terminates the loop containing it.

Control of the program flows to the statement immediately after the body of the loop. A while or for loop will iterate till the condition is tested false, but one can even transfer the control out of the loop (terminate) with help of break statement. When the break statement is executed, the control flow of the program comes out of the loop and starts executing the segment of code after the loop structure. If break statement is inside a nested loop (loop inside another loop), break will terminate the innermost loop.

Syntax: break Condition break? no Enter loop false true yes Exit loop Remaining body of loop Fig . Working of break statement The working of break statement in for loop and while loop is shown below. for var in sequence: if condition: break #code inside for loop #code outside for loop while test expression: #code inside while loop if condition: break #code inside while loop #code outside while loop 12th Computer Chapter - - for word in “Jump Statement”: if word = = “e”: break print (word, end= ' ') Output: Jump Stat Example .

: Program to illustrate the use of break statement inside for loop The above program will repeat the iteration with the given “Jump Statement”

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 →