Py Set-2
Py Set-2
Py Set-2
SET – 2
Practical: 2.1
AIM: Create a list and apply methods (append, extend, remove, reverse), arrange created
list in ascending and descending order.
Page 1|2
CE259: Programming in Python A.Y:2022-23 [EVEN] 21DCE043
Output:
Practical: 2.2
AIM: List1 = [1, 2, 3, 4, ["python", "java", "c++", [10,20,30]], 5, 6, 7, ["apple",
"banana", "orange"]] From above list get word “orange” and “Python” & repeat this list
five times without using loops.
Tools and Technologies used:
Python IDLE
Python Script
Program Code:
Practical: 2.3
AIM: Create a list and copy it using slice function.
Tools and Technologies used:
Python IDLE
Python Script
Program Code:
list1 = [27, 13, -11, 60, 39, 15]
list2 = list1[:3]
print("The original list is : ",list1)
print("The list after copying is : ",list2)
Page 2|2
CE259: Programming in Python A.Y:2022-23 [EVEN] 21DCE043
print("21DCE043")
Output:
Practical: 2.4
AIM: Create a tuple and apply different type of mathematical operation on it (Sum,
Maximum, minimum etc.).
Tools and Technologies used:
Python IDLE
Python Script
Program Code:
t1=(1,2,3,4,5)
t2=(6,7,8,9,10)
print("The original tuple t1 is : ",t1)
print("The original tuple t2 is : ",t2)
print("The maximum element of tuple is : ",max(t1))
print("The minimum element of tuple is : ",min(t1))
print("The sum of all the elements of tuple is : ",sum(t1))
t3=t1+t2
print("The addition of t1 and t2 tuples in t3 is : ",t3)
print("21DCE043")
Output:
Page 3|2
CE259: Programming in Python A.Y:2022-23 [EVEN] 21DCE043
Learning Outcomes:
In this practical, following concepts were learnt:
I. The list functions such as insert,append,remove,sort
II. We learnt how we can print the list multiple times without using loops
III. We learnt that how we can copy the list using slice function.
IV. How we can define tuples, use the different tuple functions such as max,min and
sum.
Page 4|2