Python Introduction & Setup
Python ek beginner-friendly, general-purpose programming language hai. Is first chapter me hum Python kya hai, Python 3 kaise use hota hai, first program kaise run hota hai, scripts aur interactive mode ka difference, comments, indentation ka basic idea aur BrounStack online runner se practice samjhenge.
What is Python?
Python is a high-level, general-purpose programming language known for readable syntax and a large ecosystem. It is used for automation, web backends, data work, scripting, testing, education, machine learning and many other kinds of software.
Python ka syntax relatively clean hota hai, isliye beginner logic par focus kar sakta hai instead of unnecessary boilerplate par. Lekin simple syntax ka matlab ye nahi ki Python sirf beginners ke liye hai — professional systems me bhi extensively use hota hai.
Why learn Python?
- Readable syntax se programming fundamentals samajhna easier hota hai.
- Automation scripts quickly likhe ja sakte hain.
- Web, data, AI, testing aur tooling ke liye mature libraries available hain.
- Cross-platform hai: Windows, macOS aur Linux par use kiya ja sakta hai.
- Large community aur documentation ecosystem available hai.
Use Python 3
Modern learning aur new projects ke liye Python 3 use karo. Python 2 obsolete hai and should not be chosen for new beginner work.
python --version
# or on some systems
python3 --versionExact command operating system aur installation setup par depend kar sakta hai.
BrounStack online Python runner
Is course ke examples practice karne ke liye local installation immediately required nahi hai. BrounStack Code Playground me Python code edit aur run kar sakte ho.
Your first Python program
print("Hello, BrounStack!")print() console par text output karta hai.
How Python code runs
Beginner level par tum Python ko an interpreter-driven language samajh sakte ho: source code Python runtime ko diya jata hai aur runtime instructions execute karta hai. CPython internally source ko bytecode me compile karke virtual machine par execute karta hai, so “interpreted vs compiled” ko absolute binary rule samajhna accurate nahi hai.
your_code.py → Python runtime → execution → output/error. Abhi internal bytecode details yaad karne ki zarurat nahi; important ye hai ki code ko Python runtime execute karta hai.
Python script file
Python source files commonly .py extension use karti hain.
name = "Broun"
print("Welcome,", name)A local script can commonly be run with:
python greeting.pyInteractive mode vs script
Python can also be used interactively in a REPL (Read-Eval-Print Loop), where you type an expression and immediately see its result.
>>> 2 + 3
5
>>> "BrounStack".upper()
'BROUNSTACK'- REPL: quick experiments and small checks.
- Script: repeatable programs saved in files.
- Playground: browser-based practice without local editor setup.
Comments
A comment explains code for humans and is not executed as a normal statement.
# This is a comment
print("Python practice") # inline commentIndentation matters
Python me indentation sirf visual formatting nahi hai. It defines code blocks.
age = 20
if age >= 18:
print("Adult")
print("Program finished")if statement ko Chapter 6 me detail me padhenge. Abhi sirf observe karo ki indented line condition ke block ke andar hai.
Python is case-sensitive
course = "Python"
Course = "Different variable"
print(course)
print(Course)course and Course are different names.
A first input() preview
input() user se text read kar sakta hai. Input/output ko Chapter 5 me detail me cover karenge.
name = input("Your name: ")
print("Hello,", name)Errors are normal
Programming me errors learning process ka normal part hain. Python usually error type, message and line information show karta hai.
print("Hello"This has invalid syntax because the closing parenthesis is missing. Error ko hide karne ke bajay message read karo and failing line inspect karo.
Local setup overview
Online runner se course start ho sakta hai, but later local Python install karna useful hoga for files, packages, virtual environments and larger projects.
- Python 3 official distribution ya trusted package manager se install karo.
- Terminal me version command verify karo.
- Code editor choose karo.
.pyfile create karo.- Terminal se script run karo.
Beginner best practices
- Python 3 use karo.
- Code small examples me test karo.
- Error message ko read karo before random changes.
- Consistent indentation maintain karo.
- Meaningful names use karo.
- Concept ko copy-paste se zyada edit karke test karo.
- Har example ka output predict karo, phir run karo.
Common beginner mistakes
Print()likhna instead ofprint().- Quotes ya parentheses close karna bhoolna.
- Indentation mismatch karna.
- Python 2 tutorial follow karna.
- File ko
.pyextension ke bina save karna. - Error message padhe bina code baar-baar change karna.
- REPL prompt symbols
>>>ko script file me copy kar dena.
Chapter checklist
- Python ka general purpose samajh aaya?
- Python 3 aur Python 2 ka basic difference clear hai?
print()se first output bana sakte ho?.pyscript idea samajh aaya?- REPL vs script ka difference clear hai?
- Comments aur indentation ka basic role samajh aaya?
- BrounStack Python Playground me example open kar sakte ho?
- Syntax error aane par message inspect karne ka habit clear hai?
Practice Task — First Python Session
BrounStack Playground ya local Python me ye tasks complete karo.
Hello, BrounStack!print karo.- Apna naam ek variable me rakhkar print karo.
- Do numbers ka sum print karo.
- Ek comment add karo explaining what program does.
- Text ko uppercase method ke saath experiment karo.
input()se naam lo and greeting print karo.- Intentional missing parenthesis error create karo and error message read karo.
courseandCoursenaam use karke case sensitivity observe karo.- Ek tiny
ifexample copy karke indentation change karke error/behavior observe karo. - Finally clean working version save karo.