Q.Which of the following are keywords in Python?
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →Keywords are reserved words in Python with special meanings that cannot be used as identifiers; break and while are keywords, while check and range are not. The correct keywords are (i) and (iv).
Understanding Keywords in Python
In any programming language, certain words are reserved for special purposes. These are called keywords. Think of them as the fundamental building blocks or commands that the language itself understands directly. They have predefined meanings and functionalities, and you cannot use them for anything else, such as naming your variables, functions, or classes.
The reason for this reservation is to maintain clarity and avoid ambiguity. If you could name a variable while, for instance, the Python interpreter wouldn't know if you meant to start a loop or refer to your variable. By reserving while for loops, the language remains consistent and predictable.
Python's set of keywords is relatively small and stable, making it easier to learn. Knowing which words are keywords is crucial because attempting to use a keyword as an identifier will result in a SyntaxError.
Identifying the Keywords
Let's examine each option to determine if it is a keyword in Python. A simple way to verify this in a Python environment is to use the keyword module, specifically keyword.iskeyword(), or to print the list of all keywords using keyword.kwlist.
-
(i) breakbreakis a keyword in Python.- It is used to terminate the current loop (either
fororwhile) prematurely. Whenbreakis encountered, the loop is immediately exited, and execution continues with the statement following the loop.
# Example usage of 'break' for i in range(5): if i == 3: break print(i) # Output: # 0 # 1 # 2 -
(ii) checkcheckis not a keyword in Python.- It is a regular identifier that you can use to name variables, functions, or anything else you define. For example, you could have a variable named
check = Trueor a functiondef check_status():.
-
(iii) rangerangeis not a keyword in Python.- It is a built-in function that generates an immutable sequence of numbers. While
range()is fundamental and frequently used, it is a function that you call, not a reserved word with special syntax.
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.