Video summary
Python Comments | Basic Python Synatx & Structure | 11th Computer - Ch 2 - Lec 2
Main summary
Key takeaways
Main ideas & lessons from the video
-
Basic Python syntax/structure: using
printprintis a Python keyword used for output.- To display output in the terminal (below the code editor), write:
print("your message")
- Message formatting rules:
- Anything inside the parentheses
(...)must be enclosed in quotes (double quotes in the examples). - The text appears in output exactly as typed, including:
- Capital vs small letters (e.g.,
SstaysS,cstaysc) - Punctuation (e.g., commas appear)
- Capital vs small letters (e.g.,
- Anything inside the parentheses
-
Python comments (non-executable text inside code)
- A comment is additional explanatory text written by the programmer to clarify code.
- Comments are non-executable:
- The Python interpreter does not translate them into machine/binary code.
- The interpreter does not execute or run them.
- Comments can be written in any natural language (for example, English letters using Urdu notation, etc.).
- Why we use comments (two purposes):
- Help other programmers understand your code when they read it later.
- Help you understand your own code later (after months/years).
Comment types & how to write them (detailed instructions)
-
1) Single-line comment
- Use a hash symbol at the start:
# - Everything after
#on that line is treated as a comment and is ignored by Python. - Example pattern (conceptual):
# This line explains what the code below doesprint("...")
- Use a hash symbol at the start:
-
2) Multi-line comment
- Enclose the comment text within three single quotes at the start and three single quotes at the end:
''' ... '''
- The interpreter treats everything inside as non-executable.
- It can span two or more lines for longer explanations.
- Enclose the comment text within three single quotes at the start and three single quotes at the end:
Speakers / sources featured
- Presenter: Unspecified speaker (narration by a host, starting with “Greetings dear viewers…”)
- Source referenced: A book is mentioned (“According to the book, in the very first line…”), but the title/author is not provided.