Python Keywords — Python Technical Interview Questions & Answers
Python Keywords
Python Keywords
- Keywords are reserved words. Python already uses them, so you cannot use them as variable names. if, else, for, while, def, class, return, import, try, except, True, False, None — these are the everyday ones.
- True, False, None start with a capital letter. Writing true is a NameError. class = 5 is illegal. int = 5 is allowed but ugly — don’t shadow built-in names. help("keywords") lists them if you forget.
- Viva: “keyword means reserved”. Then list six. Don’t invent new keywords.
- Python Keywords — output: True is a keyword. True/False/None start with a capital letter.
Technical Interview Tip: Define keyword + six everyday examples.
Code Examples for Python Keywords
Example
# Keywords
ok = True
if ok:
print("True is a keyword")
Python Keywords — output: True is a keyword. True/False/None start with a capital letter.
How to Explain Python Keywords to an Interviewer
Explain Keywords as if you are teaching a junior — definition, then one tiny script.
Reserved words. Not variable names. True False None are capital.
What does the example print, and why?
Python Keywords — output: True is a keyword
What mistake do freshers make with Keywords?
if / def / class / return.