Bilkul! Neeche Lab 1 se Lab 15 tak Python Programming course ke tamam labs diye gaye hain Roman Urdu mein — har lab mein:
- Short explanation
- Example code
- Student exercises
✅ Lab 1: Introduction to Python Programming
📘 Explanation:
Python aik simple aur powerful programming language hai. Yeh beginners ke liye best hai.
🧪 Example Code:
print("Hello, Python!")
📝 Exercises:
- Apna naam aur age print karo.
- Python ka version check karo using
import sys; print(sys.version)
.
✅ Lab 2: Basic Input/Output & String Operations
📘 Explanation:
input()
user se data leta hai.print()
output dikhata hai.- Strings mein text store hota hai.
🧪 Example Code:
name = input("Apna naam likho: ")
print("Welcome " + name)
📝 Exercises:
- User se naam aur city lo aur welcome message do.
- Ek string ka reverse print karo.
- String ko upper aur lower case mein convert karo.
✅ Lab 3: Boolean Logic & Logical Operators
📘 Explanation:
Boolean values sirf True
ya False
hote hain. Logical operators: and
, or
, not
.
🧪 Example Code:
a = 5
b = 10
print(a < 10 and b > 5)
📝 Exercises:
- Do numbers lo aur check karo dono positive hain ya nahi.
- Age aur marks ki condition se eligibility check karo.
✅ Lab 4: Dates and Time
📘 Explanation:
datetime
module se hum date aur time ke sath kaam karte hain.
🧪 Example Code:
import datetime
now = datetime.datetime.now()
print("Aaj ki date:", now)
📝 Exercises:
- Current date aur time print karo.
- User ka birth year lo aur uski age calculate karo.
✅ Lab 5: Conditional Statements
📘 Explanation:
if
, elif
, else
ka use conditions check karne ke liye hota hai.
🧪 Example Code:
age = int(input("Age daalo: "))
if age >= 18:
print("Adult ho")
else:
print("Underage ho")
📝 Exercises:
- Positive/negative/zero number check karo.
- Student ka grade calculate karo based on marks.
✅ Lab 6: Loops
📘 Explanation:
Loops code ko repeat karne ke liye use hotay hain.
🧪 Example Code:
for i in range(1, 6):
print("Number:", i)
📝 Exercises:
- 1 se 10 tak numbers print karo.
- 2 ka table print karo.
- While loop se countdown likho.
✅ Lab 7: Functions
📘 Explanation:
Function aik block hota hai jo bar bar use kiya ja sakta hai.
🧪 Example Code:
def greet(name):
print("Hello, " + name)
greet("Ali")
📝 Exercises:
- Function banao jo square return kare.
- Function banao jo 2 numbers ka sum de.
✅ Lab 8: Lists, Indexing, and Slicing
📘 Explanation:
List multiple items store karti hai. Indexing aur slicing se data access karte hain.
🧪 Example Code:
fruits = ["apple", "banana", "mango"]
print(fruits[1])
print(fruits[0:2])
📝 Exercises:
- List banao 5 items ke sath.
- Last item print karo.
- List mein se even numbers dhoondo.
✅ Lab 9: Numerical Operations
📘 Explanation:
Math operations like + - * /
, aur math
module ka use hota hai.
🧪 Example Code:
import math
print(math.sqrt(16))
📝 Exercises:
- Average calculate karo do numbers ka.
- Math module se factorial aur power calculate karo.
✅ Lab 10: File Handling
📘 Explanation:
Files read ("r"
) aur write ("w"
) modes mein open hoti hain.
🧪 Example Code:
file = open("data.txt", "w")
file.write("Hello, file!")
file.close()
📝 Exercises:
- Ek file create karo aur usme naam likho.
- File read karo aur output dikhayo.
✅ Lab 11: Object-Oriented Programming (OOP)
📘 Explanation:
OOP mein hum class aur objects ka use karte hain.
🧪 Example Code:
class Student:
def __init__(self, name):
self.name = name
def greet(self):
print("Hello " + self.name)
s1 = Student("Ahmed")
s1.greet()
📝 Exercises:
- Class banao Car ka jisme model aur year ho.
- Method add karo jo car ka info print kare.
✅ Lab 12: Dictionaries and Tuples
📘 Explanation:
- Dictionary key-value pair store karta hai.
- Tuple aik fixed (immutable) list hoti hai.
🧪 Example Code:
student = {"name": "Ali", "age": 21}
print(student["name"])
point = (10, 20)
print(point[0])
📝 Exercises:
- Dictionary banao kisi student ki detail ke sath.
- Tuple banao aur uska sum karo.
✅ Lab 13: Data Visualization (Matplotlib)
📘 Explanation:
Graphs aur charts ke liye matplotlib
use karte hain.
🧪 Example Code:
import matplotlib.pyplot as plt
x = [1, 2, 3]
y = [2, 4, 1]
plt.plot(x, y)
plt.title("Simple Graph")
plt.show()
📝 Exercises:
- Bar chart banao 3 fruits ke prices ka.
- Pie chart banao marks distribution ka.
✅ Lab 14: Computational Problem Solving
📘 Explanation:
Yeh lab logic aur algorithm building pe based hai.
🧪 Example Code (Fibonacci):
n = int(input("Kitne numbers chahiye Fibonacci mein? "))
a, b = 0, 1
for i in range(n):
print(a, end=" ")
a, b = b, a + b
📝 Exercises:
- Prime number check karo.
- Factorial find karo.
- String ke vowels count karo.
- Even numbers list mein se print karo.
✅ Lab 15: Error Handling and Debugging
📘 Explanation:
Errors ko handle karne ke liye try-except
use hota hai.
🧪 Example Code:
try:
num = int(input("Ek number do: "))
print(10 / num)
except ZeroDivisionError:
print("Zero se divide nahi kar sakte!")
except ValueError:
print("Sahi number do!")
📝 Exercises:
- Division ka program banao jisme user galat input de to handle ho.
- File read karte waqt error handle karo agar file na mile.