Professional Documents
Culture Documents
Title Merged
Title Merged
LAB MANUAL
Attendance Percentage
Roll No. Rubric Rubric Rubric Rubric Rubric Rubric OEL/PBL Final LAB Attendance Final weighted Score for
based based based based based based Rubric Rubric Percentage MIS System
Lab I Lab II Lab III Lab IV Lab V Lab VI Score Score [10(A)+10(B)+5(C)]/25
A B C Round to next higher
multiple of 5
Note: All Rubric Scores must be in the next higher multiple of 5 for correct entry in MIS system.
LAB MANUAL
Content Revision Team: Dr. Riaz Uddin and Dr. Mirza Muhammad Ali Baig
Approved By
CLO (Psychomotor, Level 3): Students should build various basic algorithms, analyze empirically their
growth of computational time and formulate object-oriented programming to develop basic data-structures
CLO (Affective, Level 2): Students should build various basic algorithms, analyze empirically their
growth of computational time and formulate object-oriented programming to develop basic data-structures
Total
S. No. Date Title of Experiment Signature
Marks
07-Nov-22
1 Introduction to programming with Python
14-Nov-22
2 Developing and executing algorithms using Python
26-Dec-22
7 Introduction to object oriented programming.
2. Queue
n=int(input("Number: "))
for i in range(n):
for j in range(i):
print('*',end='')
print()
for i in range(n):
for j in range(i,n):
print('*',end='')
print()
OUTPUT:
TASK 2:
Write a program which can generate the following:
>= 0.9 A
>= 0.8 B
>= 0.7 C
>= 0.6 D
< 0.6 F
try:
n =float(input("Enter score: "))
if n>=0.9 and n<=1.0:
print("A")
elif n>=0.8 and n<0.9:
print("B")
elif n>=0.7 and n<0.8:
print("C")
elif n>=0.6 and n<0.7:
print("D")
elif n>=0.0 and n<0.6:
print("F")
else:
print("Bad Score")
except:
print("Bad Score")
OUTPUT:
TASK 4:
Re-write the above program using functions.
TASK 5:
Write a Python function to calculate the factorial of a number. [Use recursive approach]
num=int(input("Please enter the number to get factorial :"))
s=1
for i in range (num,1,-1):
s=s*i
print(i,"x ",end="")
print("1 = ",s)
OUTPUT:
TASK 6:
Write a function which can search for an entry in a list. Also show the entry count in the list.
a=[1,4,5,8,9,87,67,54,3,2]
key=int(input("Enter key:"))
def search(a,key):
for i in range(0,len(a)):
if a[i]==key:
return i
d=search(a,key)
print("Entry found at",d)
OUTPUT:
TASK 7:
Develop code in python for sorting a list using selection sort approach. In selection sort you find the
minimum value first and place it at the end of the list.
a=[1,4,5,8,9,87,67,54,3,2]
key=int(input("Enter key:"))
def search(a,key):
for i in range(0,len(a)):
if a[i]==key:
return i
d=search(a,key)
print("Entry found at",d)
OUTPUT:
Laboratory Session No. 03