Loading

Quipoin Menu

Learn • Practice • Grow

python / Python Syntax
interview

Q1. What are the key syntax rules in Python?
Python uses indentation to define code blocks (4 spaces is standard). Statements are separated by newlines. Comments start with #. Variables are dynamically typed. No semicolons required. Example:
if x > 0: print("Positive")

Q2. How do you write comments in Python?
Single-line comments start with #. Multi-line comments can use triple quotes (" ... """) or multiple # lines. Docstrings (triple quotes) are used for documentation and can be accessed via help().

Q3. What is the significance of indentation in Python?
Indentation is mandatory in Python to define blocks of code (e.g. after if for def). It replaces braces {} used in other languages. Inconsistent indentation causes IndentationError. Usually 4 spaces per level is recommended.

Q4. How do you define variables in Python?
Variables are created by assignment e.g.
x = 5
No explicit type declaration needed; Python infers the type. Variable names can contain letters digits underscores but cannot start with a digit.

Q5. What are identifiers and keywords in Python?
Identifiers are names given to variables functions classes etc. They must follow naming rules. Keywords are reserved words (like if else for while def) that cannot be used as identifiers. You can view keywords with
import keyword; print(keyword.kwlist)
"