Python Basic Tutorials

Python is a high level general purpose programming language which has a clear/easy learning curve. Python programming language is massively used in various domains like Artificial Intelligence, Data Science, Web Development, Utilities Tools and Scripts and many more

Python is a Programming language, and the default Python we use is written in C programming language which is also referred to as CPython (Python implementation in C). There are various implementation of Python Programming language i.e Jython(in JAVA), Skulpt(in JS) e.t.c

To make everything easy: We refer CPython as Python

Break, Continue & Pass in Python

In python, Break, Continue, statements are used to terminate the sequential flow of a loop. Generally, Loops iterates over the block of code until a certain condition is met. But sometimes we need to terminate our program in between the execution of code. At these conditions Break, Continue statements are used.

Break statement

The break statement is the statement that helps to immediately come out of the loop when a certain given condition is met.

Example

#print the number in the list until 4 is found.
nums=[1,2,5,3,4,2]

for num in nums:
    if num==4:
        break
    print(num)
print("Hello World")
Output:

1
2
5
3
Hello World
Continue Statement

The continue statement is the statement that helps to terminate the loop for that specific iteration. The control will go to the next iteration skipping the present one.

Example:

#print the number in the list except 4
nums=[1,2,5,3,4,2]

for num in nums:
    if num==4:
        continue
    print(num)
print("Hello World")
Output

1
2
5
3
2
Hello World
Pass Statement

The pass statement in python is used in a function, loop, or class that is not implemented yet and there is nothing to do for now and you want to implement it in near future. Pass statement basically refers to null or empty. It's like a comment which does nothing but, interpreter totally ignores comments but the pass is not ignored.

Syntax:

pass

Example
    
def calculate(): #passing a function
    pass

for i in range(20): #passing a loop
    pass

class car: #passing a class
    pass