🚀 Day 1: Pehla Python Program - print() aur Strings
Python ki shaandar duniya me aapka swagat hai! Aaj aap apne programming safar ki pehli seedhi chadhne ja rahe hain. Kisi bhi nayi language ko seekhte waqt sabse pehla milestone hota hai screen par apna pehla message display karna, aur Python me yeh kaam behad aasan aur intuitive hai.
1. 💡 Concept: print() se pehli line
Python ko 1991 me Guido van Rossum ne banaya tha, aur unka sabse bada maqsad yeh tha ki code padhna aur likhna English ki tarah bilkul aasan ho. Doosri languages jaise C ya Java me ek simple line print karne ke liye 5 se 7 lines ka boilerplate code likhna padta hai, lekin Python me sirf ek line kaafi hoti hai: print("Hello World!").
Analogy: Socho Python interpreter ek obedient robot dost hai jo aapke diye gaye instructions ko line by line follow karta hai. Jab aap use bolte ho print(), toh aap asal me robot ko keh rahe ho: "Bhai, parentheses ke andar jo kuch bhi likha hai, use screen par laakar dikha do!"
Ab samajhte hain ki print() function kaise kaam karta hai aur iske core elements kya hain:
- Function Name:
printek built-in function hai jo Python me pehle se bana-banaya milta hai. Python case-sensitive hai, isliye yeh hamesha lowercase me hi likha jana chahiye. - Parentheses
(): Function ke aage round brackets lagte hain. Iske andar hum jo data bhejte hain, use technical terms me arguments kaha jata hai. - Quotes ka Rule: Jab hum computer ko koi text (text string) print karne ko kehte hain, toh use quotes me pack karna zaroori hota hai taaki Python ko pata chale ki yeh plain text hai, koi command ya variable nahi.
- Single vs Double Quotes: Python me
'Hello'aur"Hello"me koi farak nahi hai. Dono bilkul barabar kaam karte hain. Double quotes tab bohot useful hote hain jab text ke andar apostrophe ho, jaise"It's a great day". - Triple Quotes (
'''ya"""): Agar aapko multiple lines ka paragraph ya formatted art print karna hai bina baar baarprint()likhe, toh triple quotes ka use kiya jata hai. - sep aur end parameters:
print()ke paas do hidden superpowers hain.sepbatata hai ki multiple items ke beech kya aayega (default space hai), aurendbatata hai ki line ke aakhri me kya aayega (default newlinehai).
Programming me Comments ek bohot zaroori tool hain. Jab aap kisi line ke shuru me # symbol lagate hain, toh Python interpreter us line ko bilkul ignore kar deta hai. Yeh comments hamare khud ke samajhne ke liye aur team members ko code explain karne ke liye likhe jaate hain.
2. 💻 Live Demo: Strings, Quotes aur Formatting
Neeche diye gaye code ko dhyaan se dekhein aur dekhein ki quotes aur parameters kaise behave karte hain:
# Single quotes aur Double quotes dono perfectly valid hain:
print('Namaste Doston!')
print("Python seekhna behad aasan hai.")
# Handling quotes inside strings:
print("Python developer ne kaha: 'Keep coding daily!'")
print('It's a wonderful journey to master programming.')
# Multiple items print karna with sep parameter:
print("Python", "JavaScript", "C++", sep=" | ")
# end parameter ka magic (agli line me jaane ke bajaye same line me continue):
print("Loading Python modules...", end=" ")
print("Done!")Python seekhna behad aasan hai.
Python developer ne kaha: 'Keep coding daily!'
It's a wonderful journey to master programming.
Python | JavaScript | C++
Loading Python modules... Done!
Ab dekhte hain triple quotes aur comments ka practical istemaal ek professional banner create karne ke liye:
# ==========================================
# Script: Day 1 Welcome Dashboard
# Developer: Python Learner
# Purpose: Multi-line strings & clean structure
# ==========================================
print("""
========================================
PYTHON 30-DAY BOOTCAMP: DAY 1
========================================
Target: Master the Core Fundamentals
Status: In Progress 🚀
Rule: Code every day without skipping!
========================================
""")
# Variables ko introduce karte hain (bina quotes ke print karna):
user_name = "Rahul Sharma"
day_number = 1
print("Welcome", user_name, "to Day", day_number, "of Python Mastery!")PYTHON 30-DAY BOOTCAMP: DAY 1
========================================
Target: Master the Core Fundamentals
Status: In Progress 🚀
Rule: Code every day without skipping!
========================================
Welcome Rahul Sharma to Day 1 of Python Mastery!
Beginners aksar variable ki value print karte waqt variable ke naam par quotes laga dete hain, ya Python ke lowercase functions ko Capital letter se likh dete hain.
Galti 1: Variable name par quotes lagana:
❌ Wrong:
my_name = "Aman"
print("my_name") # Output aayega: my_name (literal text!)
✅ Correct:
my_name = "Aman"
print(my_name) # Output aayega: Aman (variable ki stored value!)
Galti 2: Case sensitivity bhool jana:
❌ Print("Hello") ya PRINT("Hello") → NameError: name 'Print' is not defined.
✅ print("Hello") → Python me keywords aur built-in functions case-sensitive hote hain, small letters me likhein!
Real Life Scenario: Production backend applications me print() statements debugging, log verification, aur server start hone par diagnostics print karne ke liye sabse pehla tool hote hain. Jab server run hota hai, console par banner print karke bataya jata hai ki API live hai ya database connected hai.
Interview Question: "What does the print() function actually return in Python?"
Answer: Python me print() function screen par text display karta hai, lekin iska return value hamesha None hota hai. Agar aap x = print("Hi") likhenge, toh screen par "Hi" print hoga aur variable x ke andar None store hoga.
Mini Practice Task: Ek aisi Python script likhiye jo aapka naam, aapka target domain (e.g. Data Science, Web Dev, ya AI), aur aapka target package ek stylish box ke format me print kare.