Python Keywords

 Python Keywords



Python Keywords are exceptional held words that pass on a unique significance to the compiler/mediator. Every catchphrase has an extraordinary significance and a particular activity. These catchphrases can't be utilized as a variable. Following is the List of Python Keywords.

Think about the accompanying clarification of catchphrases.

1. True - It addresses the Boolean valid, in the event that the given condition is valid, then, at that point, it returns "Valid". Non-zero qualities are treated as obvious.

2. False - It addresses the Boolean bogus; assuming the given condition is bogus, then, at that point, it returns "Bogus". Zero worth is treated as bogus

3. None - It means the invalid worth or void. An unfilled rundown or Zero can't be treated as None.

4. and - It is a sensible administrator. It is utilized to actually look at the various conditions. It returns valid assuming that the two conditions are valid. Consider the accompanying truth table.

5. 5. or on the other hand - It is a consistent administrator in Python. It returns valid assuming one of the conditions is valid. Consider the accompanying truth table.

6. 6. not - It is a legitimate administrator and upsets reality esteem. Consider the accompanying truth table.

7. affirm - This catchphrase is utilized as the troubleshooting instrument in Python. It actually takes a look at the rightness of the code. It raises an AssertionError whenever tracked down any blunder in the code and furthermore prints the message with a mistake.

Model:

1. a = 10

2. b = 0

3. print('a is isolating by Zero')

4. assert b != 0

5. print(a/b)

8. def -

 This watchword is utilized to announce the capacity in Python. Whenever followed by the capacity name.

1. def my_func(a,b):

2. c = a+b

3. print(c)

4. my_func(10,20)

9. class -

 It is utilized to addresses the class in Python. The class is the outline of the items. It is the assortment of the variable and strategies. Think about the accompanying class.

1. class Myclass:

2. #Variables… … ..

3. def function_name(self):

4. #statements… … …

10. proceed - It is utilized to stop the execution of the current cycle. Think about the accompanying model.

1. a = 0

2. while a < 4:

3. a += 1

4. if a == 2:

5. proceed

6. print(a)

11. break - It is utilized to end the circle execution and control move to the furthest limit of the circle. Think about the accompanying model.

Model

1. for I in range(5):

2. if(i==3):

3. break

4. print(i)

5. print("End of execution")

12. If - It is utilized to address the restrictive assertion. The execution of a specific square is chosen by if articulation. Think about the accompanying model.

Model

1. i = 18

2. if (1 < 12):

3. print("I am under 18")

13. else - The else explanation is utilized with the if proclamation. When on the off chance that assertion returns bogus, then, at that point, else block is executed. Think about the accompanying model.

Model:

1. n = 11

2. if(n%2 == 0):

3. print("Even")

4. else:

5. print("odd")

14. elif - This Keyword is utilized to actually take a look at the numerous conditions. It is short for else-if. On the off chance that the past condition is bogus, then, at that point, check until the genuine condition is found. Condition the accompanying model.

Model:

1. marks = int(input("Enter the marks:"))

2. if(marks>=90):

3. print("Excellent")

4. elif(marks=75):

5. print("Very Good")

6. elif(marks=60):

7. print("Good")

8. else:

9. print("Average")

15. del -

 It is utilized to erase the reference of the article. Think about the accompanying model.

Model:

1. a=10

2. b=12

3. del a

4. print(b)

5. # an is presently don't exist

6. print(a)

16. attempt, with the exception of - The attempt aside from is utilized to deal with the special cases. The special cases are run-time blunders. Think about the accompanying model.

Model:

1. a = 0

2. try:

3. b = 1/a

4. except Exception as e:

5. print(e)

17. raise - The raise catchphrase is utilized to through the special case powerfully. Think about the accompanying model.

Model

1. a = 5

2. if (a>2):

3. raise Exception('a ought not surpass 2 ')

18. at last - The at long last catchphrase is utilized to make a square of code that will forever be executed regardless of the else block raises a mistake or not. Think about the accompanying model.

Model:

1. a=0

2. b=5

3. try:

4. c = b/a

5. print(c)

6. except Exception as e:

7. print(e)

8. finally:

9. print('Finally consistently executed')

19. for, while - Both catchphrases are utilized for cycle. The for catchphrase is utilized to repeat over the arrangements (list, tuple, word reference, string). Some time circle is executed until the condition returns bogus. Think about the accompanying model.

Model: For circle

1. list = [1,2,3,4,5]

2. for I in list:

3. print(i)

Model: While circle

1. a = 0

2. while(a

Post a Comment

0 Comments