Jump statment in python

RaginiJain21 678 views 13 slides Jul 18, 2021
Slide 1
Slide 1 of 13
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13

About This Presentation

In this PPT you will learn about how to use jump statement.Using these jump statement you can jump in any statement.
You get a new presentation every Sunday at 10 AM.
Learn more about python by clicking on this given below link
Python Introduction- Python Introduction- https://www.slideshare.net/Rag...


Slide Content

Jump Statements

Types of Jump Statements Break Continue Pass

BREAK STATEMENT break statement is used to exit from the iterative statements (loops) such as for, while. Use case of this statement terminates the execution of loop immediately, and then program execution will jump to the next statements.

SYNTAX for var in sequence: statement1 statement2 if condition: break

example list = [1,2,3,4,5,6]  a =0  b =0  for num in list :          print num          a+=num          b+=1          if (b == 3):               break   print "sum is =%d"%(a) 1 2 3 sum is =6 Output

CONTINUE STATEMENT continue statement is used to continue the loop execution i.e. to get back to the top of the iterative statements (loops) such as for, while. Use case of this statement stops the further statement execution of loop immediately.

a=0  for b in range (1,7):     a+=b     b+=1     if (b == 5):      continue      print “b is:%d"%(b)  print "sum is =%d"%(a) example

b is:2 b is:3 b is:4 b is:6 b is:7 sum is =22 output

PASS STATEMENT pass statement is used when programmer don’t want to execute a set of code. pass statement is null operation. So, nothing will happen when pass statement has been executed. Mostly, programmer uses the pass statement when they don’t want to execute the code, but they want the syntactical expressions. You use pass statement when you create a method that you don't want to implement, yet.

syntax def  passMethod ():      pass print('hello') output hello

Example without using pass statement def  myMethod (): print('hello') Traceback (most recent call last): File "python", line 3    print('hello') IndentationError : expected an indented block Output

For more presentation in any subject please contact us on [email protected]