Control statements(Break, Continue, Pass) in Python.
Control Statement
Control statement allow a programmer to control the flow of program according to their need. Control statements are break, continue and pass.
Break Statement
The break statement allow a programmer to terminate a loop, when the break statement is encountered inside the loop,the loop is immidiately terminated and program control automatically goes to first statement.
Break statement in while loop
Break statement in for loop
Write a program to demonstrate the use of break statement.
output
Continue Statement
The continue Statement is exactly opposite to the break statement, Continue statement is encountered within a loop the remaining statement within the body are skipped but the loop condition checked to see if the loop should continue or exit.
Continue statement in while loop
Continue statement in for loop
Write a program to demonstrate the use of continue statement.
output
Pass Statement
Pass statement is used to give a empty loop to a program. We are using pass statement for empty control statement.
Comments
Post a Comment