Python Keywords List and Uses

Python Keywords List and Uses
Python Keywords List and Uses

What is Python Keywords: Keywords are predefined reserved words used in python programming that have special meanings to the compiler Keywords are part of the syntax and they cannot be used as an identifier. The word which is pre-defined in the library is called keyword. It's functionality is also pre-defined. Keyword can not be used as a variable, function name ,class name or as an any identifier.

How Many Keywords in Python

False await None
Break except in
True and as
class finally is
else import continue
for def assert
del async elif
from if global
not pass raise
lambda try or
return while with
yield nonlocal self
Python True False Keywords: A python true and false value is a boolean value. It can be used if value are true than result true or value are false than result is false.

Example of True and False Keyword in Python

x=True
y=False
print(x)
print(y)

============OUTPUT============
True 
False

Async and Await Keywords in Python: A python await Keyword can be used to stop the execution of python program.

Example of Await Keyword in Python

import asyncio
async def welcome():
          print("Welcome To")
          await asyncio.sleep(3)
          print("Jiocoding")
asyncio.run(welcome())

============OUTPUT============
Welcome To
Jiocoding

None Keyword with Example: A None Keyword can be used no value present in our python program.

Example of None Keyword in Python

def wish(name):
       print("Website:", name)
data=wish("jiocoding")
print(data)

============OUTPUT============
Website: Jiocoding
None

Break and Continue in Python: A break Keyword can be used termite the current loop. It is very important because break statement are stop until the given condition.

Example of Break in Python

for i in range(1,10):
        if i==5:
              break
        print(i)

============OUTPUT============
1
2
3
4

Continue Keyword: A python continue keyword can be used to skip the loop iteration. It is skip value given condition.

Example of Continue in Python

for i in range(1,11):
        if i==5:
              continue
        print(i)

============OUTPUT============
1
2
3
4
6
7
8
9
10

Use of Class Keyword in Python: A python class keyword is most important in object oriented programming language because class is a blue print in our python program.

Example of Class Keyword in Python

class jiocoding:
            id=101
            name="Welcome"
j=jiocoding()
print(j.id)
print(j.name)
         
============OUTPUT============
101
Welcome

Lambda Keyword in Python: Lambda keyword is a very most important and useful function. Lambda function other name anonymous function.

Example of Lambda Keyword in Python

res=lambda x,y: x+y
print("Result is:",res(5,6))

============OUTPUT============
Result is:11

Yield Keyword in Python: A yield is a generator because it can be used generate value on the fly. Yeild Keyword is a saved our memory.

Example of Yield Keyword in Python

def student_data():
        data=["Hello","Python","jiocoding"]
        for i in data:
              yeild i
for name in student_data()
       print(name)
       
============OUTPUT============

Raise Keyword in Python: A raise Keyword can be used exceptions handling if our program any error than raise Keyword solved our problem.

Python User Input String

try:
     x=int(input("Enter Value:"))
     if x==0:
         raise Zero division error("Zero is not acceptable")
except Zero division error as ex:
    print("Error Message:",ex)

============OUTPUT============
Enter Your Name: Jiocoding
Your Name is: Jiocoding
<class 'str'>

Conclusion of Keyword in Python

Conclusion: This is a conclusion of python keyword. It is a keyword can be used are reserved keywords can not be used identifier name. I can explain everyone topic briefly details in next article. If your any query python keyword related than you can contact me by email or comment.

Post a Comment

0 Comments