Interview Question

What are comments in Python?

Use # for comments; docstrings are string literals used as documentation.

💡 Concept ✅ Quick Revision 🐍 Python

Answer

A Python comment begins with # and continues to the end of the physical line. • Comments are ignored as program instructions. • String literals are not comments, although docstrings document modules, classes, and functions. • Useful comments explain intent rather than repeat obvious code.

💡 Simple Example

# Calculate the final price after discount. price = 100 * 0.9 print(price)

Output

90.0

⚡ Quick Revision

Use # for comments; docstrings are string literals used as documentation.