Computer Programming Labs 24CE (Roman Urdu)

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

Table of Contents

โœ… 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:

  1. Apna naam aur age print karo.
  2. 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:

  1. User se naam aur city lo aur welcome message do.
  2. Ek string ka reverse print karo.
  3. 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:

  1. Do numbers lo aur check karo dono positive hain ya nahi.
  2. 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:

  1. Current date aur time print karo.
  2. 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:

  1. Positive/negative/zero number check karo.
  2. 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. 1 se 10 tak numbers print karo.
  2. 2 ka table print karo.
  3. 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:

  1. Function banao jo square return kare.
  2. 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:

  1. List banao 5 items ke sath.
  2. Last item print karo.
  3. 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:

  1. Average calculate karo do numbers ka.
  2. 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:

  1. Ek file create karo aur usme naam likho.
  2. 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:

  1. Class banao Car ka jisme model aur year ho.
  2. 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:

  1. Dictionary banao kisi student ki detail ke sath.
  2. 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:

  1. Bar chart banao 3 fruits ke prices ka.
  2. 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:

  1. Prime number check karo.
  2. Factorial find karo.
  3. String ke vowels count karo.
  4. 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:

  1. Division ka program banao jisme user galat input de to handle ho.
  2. File read karte waqt error handle karo agar file na mile.

Leave a Comment

Your email address will not be published. Required fields are marked *

wpChatIcon
wpChatIcon
Scroll to Top