Break, Continue, Pass Work and self In Python

Break, Continue And Pass Work In Python
Break, Continue And Pass Work In Python

How does break, continue and pass work in python?

Break is a keyword used as a statement in loops (eg- if-else, while, etc)to terminate the current loop or to exit the current loop execution and continues with the next statement/ loop.
while a > 0:
print(‘value :’, a)
a = a -1
if a == 5:
break

Continue is a keyword used as a statement to give back the control to the beginning of the loop (while, for, etc). It rejects/ eliminates all the other statements that are followed in the current iteration of the loop.
if value == ‘hello’:
continue

Pass is a keyword used as a statement for null operation. It does nothing. This type of statement is used in code blocks where the code is no longer required by the coder.
for a in x:
if value == ‘hello’:
pass
print ‘This is a pass block’
print (‘value :’, a)

Write a Python program to print the documents (syntax, description etc.) of Python built-in function(s).

Python documentation strings or docstrings are string literals that describe what a function does. As the name suggests, it documents the syntax and description and return type of the function. It is associated with python modules, functions, classes and methods. In this case, let’s take built-in functions- abs(), sum().
-print(abs.doc)
-output: Return the absolute value of the argument.

-print(sum.doc)

-output:
Return the sum of a ‘start’ value (default: 0) plus an iterable of numbers

When the iterable is empty,return the start value.
This function is intended specifically for use with numeric values and may
reject non-numeric types.

What is self in Python?

Self is a keyword that is used in class as an instance parameter or a reference parameter. Its main goal is to help access the variables, attributes and methods belonging to that class.

Summary :

In this article we saw Break, Continue Pass Work and self in In Python so any query about this article then please free to ask.

Intern name who share this task : Vanshika Jain

This is the attached link to my github project.
https://github.com/EXPLORER-ON-BOARD/INTERNSHIP

Also see following python arduino base projects

python code for robot arm controller using arduino

interconnection between python ide with arduino uno

plotting real time data from arduino uno using python code

python code for iot notes printer using arduino due

I am the founder of Pythonslearning, a Passionate Educational Blogger and Author, who love to share the informative content on educational resources.

Leave a Comment