What is pass instruction ?
The pass statement does nothing. It can be used when an instruction is required to provide correct syntax, but no action should be taken.Examples of using the pass instruction
If we want to exclude only minors!
age = int(input("Type youre age :"))
if age > 18:
pass
else:
print("You are a minor !")
This instruction is commonly used to create minimal classes:
class MyEmptyClass:
pass
If we want to create a class with constructor without parameters:
class MyEmptyClass:
def __init__(self):
pass
Younes Derfoufi
my-courses.net
my-courses.net
No comments:
Post a Comment