1. Functions

Function ek code ka block hota hai jo specific kaam karta hai. Isse code reusable banta hai.
Key concepts: def keyword, arguments, return statement.

# Function definition
def greet(name):
    return "Hello " + name

# Function calling
msg = greet("Rahul")
print(msg)  # Output: Hello Rahul

2. File Handling

Python se hum text files (.txt), binary files (.dat) aur CSV files ko read/write kar sakte hain. Useful for storing data permanently.
Modes: 'r' (read), 'w' (write), 'a' (append).

# Writing to a text file
f = open("data.txt", "w")
f.write("Confidential Data")
f.close()

# Reading a text file
f = open("data.txt", "r")
print(f.read())
f.close()

3. Stack (Data Structure)

Stack follows LIFO (Last In First Out) principle. Jaise plates ka stack - jo last mein rakhi wo pehle uthegi.
Operations: Push (Add), Pop (Remove).

stack = []
stack.append(10) # PUSH
stack.append(20)
print(stack.pop()) # POP -> Output: 20
Google Ad Here

Quiz Time!

Q1. Which keyword is used to define a function?

(a) func (b) define (c) def (d) function

Q2. Which mode is used to append data to a file?

(a) r (b) w (c) a (d) x