Python course for beginners

Python प्रोग्रामिंग कोर्स (हिंदी + English)

Start with what a program is and how to read your first error. Then learn print and variables, data types and a small calculator, decisions with if/elif/else, for and while loops, lists and dictionaries, functions, f-strings, input() with int(), error handling with try/except, and classes and objects. The capstone is a report-card manager that uses lists of dictionaries, lambda and comprehensions.

शुरुआत इससे कि program क्या होता है और पहली error कैसे पढ़ें। फिर print और variables, data types और छोटा calculator, if/elif/else से फ़ैसले, for और while loops, lists और dictionaries, functions, f-strings, input() और int(), try/except से error handling, और classes व objects। आख़िर में एक report-card manager बनता है जिसमें lists of dictionaries, lambda और comprehensions इस्तेमाल होते हैं।

How the code runs: Code runs in a small Python interpreter written in JavaScript that covers everything used in these lessons. It is not the full Python language; for bigger programs, install Python from python.org. Code JavaScript में लिखे एक छोटे Python interpreter में चलता है, जो इन lessons की सारी चीज़ें सपोर्ट करता है। यह पूरा Python नहीं है; बड़े programs के लिए python.org से Python इंस्टॉल करें।

Start chapter 2.0 in the live classroomRead chapter 2.0 first

Start Here level (शुरुआत)

  1. 2.0Start Here: What is a Program? (Hello + Your First Error)

    शुरुआत: प्रोग्राम क्या है? (Hello + आपकी पहली Error)

    A program runs top to bottom, one line at a time.

Basic level (बेसिक)

  1. 2.1Talk to the Computer (print & Variables)

    कंप्यूटर से बात करो (print और जादुई डिब्बे)

    print(...) shows output on the screen.

  2. 2.2Data Types & Smart Calculator (+, -, *, /)

    4 डेटा टाइप्स और स्मार्ट कैलकुलेटर (+, -, *, /)

    Four basic types: str (text), int (whole number), float (decimal), bool (True/False).

  3. 2.3Decision Power (if, elif, else)

    फ़ैसला लेने की शक्ति (if, elif, else)

    if, elif and else let the program choose a path.

  4. 2.4Loops (for — Automatic Robot Machine!)

    लूप्स (for — बार-बार काम करने वाली ऑटोमैटिक मशीन!)

    for i in range(5): repeats the indented block 5 times.

Intermediate level (इंटरमीडिएट)

  1. 2.5Lists & Dictionaries (Train Bogies & Contact Book)

    लिस्ट [ ] और डिक्शनरी { } (ट्रेन के डिब्बे)

    A list [ ] stores many values in order: fruits = ["Apple", "Mango"].

  2. 2.6Functions (def — Doraemon's Gadget Pocket!)

    फ़ंक्शन्स (def — डोरेमोन की जादुई मशीन!)

    def name(params): builds a reusable function once.

  3. 2.7Bonus: Modern f-Strings & while Rocket Countdown

    बोनस: आधुनिक f-Strings और while रॉकेट काउंटडाउन

    An f-string puts variables inside text: f"Score: {points}".

  4. 2.8Talking to the User: input(), int() & String Superpowers

    यूज़र से बात: input(), int() और String की ताक़तें

    input() always returns text — wrap it in int() / float() for maths.

Pro level (प्रो)

  1. 2.9Error Handling: try / except (Programs That Never Crash)

    Error Handling: try / except (कभी न रुकने वाले प्रोग्राम)

    Risky code goes in try:; the rescue goes in except ErrorType:.

  2. 2.10OOP in Python: Classes & Objects (Make Your Own Game Character)

    Python में OOP: Classes और Objects (अपना गेम कैरेक्टर बनाओ)

    Class = blueprint, object = real thing made with ClassName(...).

  3. 2.11Capstone: Report Card Manager (lists of dicts, lambda, comprehensions, modules)

    कैपस्टोन: रिपोर्ट कार्ड मैनेजर (dicts की list, lambda, comprehension, modules)

    Store records as a list of dictionaries.

Practice problems

Each problem is linked to a chapter. Read them on the practice page and solve them in the Practice Zone.

Viva and interview questions

Why is Python so popular for beginners and AI?

School Viva

Python reads almost like plain English, needs far fewer lines of code than C++/Java, and has the world's richest AI & Data Science ecosystem (scikit-learn, PyTorch, TensorFlow).

Python शुरुआती छात्रों और AI के लिए दुनिया की नंबर-1 भाषा क्यों है?

Python बिल्कुल आसान अंग्रेज़ी जैसी दिखती है, कम लाइनों में बड़ा काम करती है, और दुनिया की सबसे मज़बूत AI लाइब्रेरीज़ (scikit-learn, PyTorch) इसी में हैं।

What is Indentation in Python and what happens if you skip it?

Practical Exam

Python uses 4 leading spaces instead of { } braces to group code inside if, for, while, and def. Skipping it raises an IndentationError.

Python में Indentation (4 Spaces) क्या है और इसे छोड़ने पर क्या होता है?

Python में { } की जगह लाइन की शुरुआत में 4 स्पेस देकर बताया जाता है कि कौन-सी लाइन if, for या def के अंदर है। इसे भूलने पर IndentationError आता है।

What is the difference between a Python list [ ] and dict { }?

Interview

A List stores ordered items accessed by numeric position (items[0]). A Dictionary stores key: value pairs accessed by meaningful key names (student["naam"]).

Python में List [ ] और Dictionary { } में क्या अंतर है?

List [ ] क्रम से रखे आइटम्स की सूची है जहाँ नंबर ([0], [1]) से सामान निकालते हैं। Dictionary { } में नाम: वैल्यू की जोड़ी होती है (student["naam"])।

Difference between = and == in Python?

School Viva

= is the Assignment operator (x = 10 puts 10 into box x). == is the Comparison operator (x == 10 checks if x equals 10 and returns True or False).

Python में = और == में क्या अंतर है?

= वेरिएबल डिब्बे में वैल्यू रखने का चिह्न है (x = 10), जबकि == दो चीज़ों की तुलना करके True या False बताता है!

Difference between print() and return inside a Python function?

Practical Exam

print() merely displays text on the screen, whereas return sends the calculated value back to the caller so you can store it in a variable or use it in further math!

फ़ंक्शन के अंदर print() और return में क्या अंतर है?

print() सिर्फ़ स्क्रीन पर दिखाता है, जबकि return फ़ंक्शन का असली नतीजा बाहर वापस भेजता है ताकि उसे किसी वेरिएबल में सेव करके आगे इस्तेमाल किया जा सके!

When should you use a for loop vs a while loop?

Interview

Use for when you know the collection or number of turns upfront (range(10) or a list). Use while when repeating until a dynamic condition changes (e.g., while fuel > 0:).

for लूप और while लूप कब-कब इस्तेमाल करने चाहिए?

जब चक्करों की संख्या या लिस्ट पहले से पता हो तो for लूप लगाएँ। और जब किसी शर्त के सच रहने तक काम दोहराना हो (while count > 0:) तब while लूप लगाएँ।

Why do we use try/except instead of letting the program crash?

Interview

Users type unexpected things (e.g. "abc" for a number). try: runs the risky code and except ValueError: shows a friendly message, so the program keeps running. finally: runs the clean-up every time.

प्रोग्राम को crash होने देने की जगह try/except क्यों इस्तेमाल करते हैं?

यूज़र अनचाही चीज़ें लिख देते हैं (जैसे नंबर की जगह "abc")। try: जोखिम वाला कोड चलाता है और except ValueError: प्यारा संदेश दिखाता है, इसलिए प्रोग्राम चलता रहता है। finally: हर बार सफ़ाई वाला काम करता है।

What is self in a Python class?

School Viva

self is the object that called the method. In arjun.take_hit(30), inside take_hit the word self means arjun, so self.hp is Arjun’s own HP.

Python class में self क्या है?

self वह object है जिसने method बुलाया। arjun.take_hit(30) में, take_hit के अंदर self का मतलब arjun है, इसलिए self.hp अर्जुन की अपनी HP है।

What is a list comprehension? Give an example.

Interview

A short way to build a list in one line: [s["name"] for s in students if s["marks"] >= 60] gives the names of all students with 60 or more marks.

List comprehension क्या है? एक उदाहरण दो।

एक लाइन में list बनाने का छोटा तरीका: [s["name"] for s in students if s["marks"] >= 60] उन सभी छात्रों के नाम देता है जिनके 60 या ज़्यादा marks हैं।

Ready mini projects

Open them in the Projects section of the classroom to run and change the code.