Level 1: print() Function & Python Output - Master Notes
Stage: Foundation | Level: 1 | Title: "Hello, Python!"
1. Theoretical Background: print() Function
- print() ek built-in function hai Python mein jiska kaam hota hai kuch bhi output dena screen par.
- Yeh sabse basic aur important command hai. Isse tu apne code ke results, messages, aur
debugging outputs dekh sakta hai.
2. Syntax & Usage
print("Kuch bhi text ya variable")
Basic Rules:
- Double "" ya single '' quotes dono chalega for strings.
- Parentheses () compulsory hai Python 3 mein.
3. Advanced Features of print()
Feature | Description | Example | Output
----------------------------------------------------------------------
String | Text | print("Hello") | Hello
Numbers | Maths | print(5 + 3) |8
Variables | Variables | x = 10; print(x) | 10
end argument | End change | print("Hello", end=" ") | Hello
sep argument | Separator | print("A", "B", sep="-") | A-B
Escape chars | Formatting | print("Line1\nLine2") | Line1
Line2
f-strings | Formatting | name = "Ritesh"; print(f"Name: {name}") | Name: Ritesh
4. Escape Characters
\n - New line
\t - Tab space
\\ - Backslash
\' - Single quote
\" - Double quote
5. Application in Maths & Physics
Use Case | Description
------------------------------------------
Math | Print formulas: print(f"Area = {l*b}")
Physics | Solve and print: print(f"Force = {m*a}")
Lab Reports | Print sensor outputs
Graphs | Labeling and output display
Simulations | Step-by-step particle tracking
6. Revision Tips:
- print() hamesha parentheses ke sath likhna.
- Strings ke liye "" ya '' use kar.
- Agar multiple cheezein print kar raha ho to comma use kar.
- Format karna hai: use f"...{var}".
- Multiple lines ke liye: \n
7. Summary Notes (Pocket Size)
print("text") - basic printing
print("a", "b") - space by default
print("a", "b", sep="-") - separator control
print("a", end="") - line ending control
\n = new line | \t = tab | \" = quote
f"...{var}" - formatted printing
Jarvis Tip:
Jitna achhe se print() samjhega, utni easily tu aage ke concepts jaise functions, loops, files, aur data
visualization kar paayega.