SIDDEEQ PUBLIC SCHOOL AND COLLEGE
PYTHON PROGRAMMING ASSIGNMENT
Student Name: Hassan Irfan
Class: ICS-II
Roll No: B-7546
Teachers: Sir Zeeshan & Sir Junaid
Table of Contents
1 Basic Programs
2 Loop-Based Programs
3 Sorting Algorithms
4 Searching Algorithms
Basic Programs
Largest and Smallest Number
numbers=[12,5,7,25,3,19]
print(max(numbers), min(numbers))
Output: Largest=25, Smallest=3
Sum of List
numbers=[4,6,8,10]
print(sum(numbers))
Output: 28
Loop-Based Programs
Even/Odd
for n in range(1,21):
print(n)
Output: Even/Odd lists generated
Factorial
num=5
fact=1
for i in range(1,num+1): fact*=i
Output: 120
Sorting Algorithms
Bubble Sort Asc
arr=[5,2,9,1]
...
Output: [1,2,5,9]
Bubble Sort Desc
arr=[5,2,9,1]
...
Output: [9,5,2,1]
Searching Algorithms
Linear Search
arr=[4,7,1,9]
...
Output: Found at index 3
Binary Search
arr=[1,3,5,7]
...
Output: Found at index 3