0% found this document useful (0 votes)
13 views6 pages

12CS ProgramBasedTest3

The document contains a series of programming exercises focused on list operations in Python, including appending, extending, inserting, and deleting elements. It also covers the use of tuples, dictionaries, and sets, along with their respective operations. The exercises are designed to help students understand and practice basic data structures and their manipulations in Python.

Uploaded by

tvm.ict7
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views6 pages

12CS ProgramBasedTest3

The document contains a series of programming exercises focused on list operations in Python, including appending, extending, inserting, and deleting elements. It also covers the use of tuples, dictionaries, and sets, along with their respective operations. The exercises are designed to help students understand and practice basic data structures and their manipulations in Python.

Uploaded by

tvm.ict7
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

12 – COMPUTER SCIENCE

LESSON – 9

என்றும் மாணவர்கள் நலனில்

WRITE THE OUTPUT OF THE FOLLOWING SNIPPETS. / பின்வரும் குறிமுறைகளின் வெளியீட்டை எழுதுக.
1) Write the number of elements in the following list:/ பின்வரும் பட்டியலில் உள்ள
உறுப்புகளின் எண்ணிக்கககய எழுதவும்:

Mylist = [ “Welcome”, 3.14, 10, [2, 4, 6] ]

2) Mylist = [ “Welcome”, 3.14, 10, [2, 4, 6] ]


print(Mylist)
print(Mylist[0])
print(Mylist[1])
print(Mylist[-2])
print(Mylist[-1])
print(Mylist[-1][1])

3) Mylist1 = [ "Welcome", 3.14, 10, [2, 4, 6] ]


Mylist2 = [ "Welcome", 3.14, 10, 2, 4, 6 ]
print("Number of elements in list1 is",len(Mylist1))
print("Number of elements in list2 is",len(Mylist2))

4) Mylist = [ 2, 4, 6 ]
[Link](8)
[Link]([10, 14])
[Link](5,12)
print(Mylist)

5) Find the correct statement to add multiple elements to the list “Mylist=[2,4,6]”
/ "Mylist=[2,4,6]" என்ற List-ல் பல உறுப்புககளச் சேர்க்க பயன்படும் ேரியான

கூற்கைக் கண்டைியவும்.

(a) [Link](8, 10)


(b) [Link]([8,10])

..1.. A. PRABHAKAR - 9442979144


6) Mylist = [ 2, 4, 6 ]
[Link](0,0)
[Link]([8])
[Link](14)
[Link](5,12)
print(Mylist)

7) Mylist = [ 2, 4, 6 ]
[Link](0,0)
[Link]([8])
[Link](14)
[Link](5,12)
i=-1
while i >= -7:
print(Mylist[i])

8) Mylist = [ 0, 2, 4, 6, 8, 10, 12, 12, 14 ]


del(Mylist[7])
del(Mylist[1:4])
print(Mylist)

9) Mylist = [ 0, 2, 4, 6, 8, 10, 12, 12, 14 ]


del(Mylist[7])
del(Mylist[1:4])
del(Mylist[0])
print(Mylist)
del Mylist

10) Mylist = [ 0, 2, 4, 6, 8, 10, 12, 14, 16 ]


del(Mylist[4])
print(Mylist)
del(Mylist[:4])
print(Mylist)
del(Mylist[2:])
print(Mylist)

11) Mylist = [ 0, 2, 4, 6, 8, 8, 10, 12, 14 ]


[Link](8)
print(Mylist)
[Link](2)
print(Mylist)

..2.. A. PRABHAKAR - 9442979144


12) Mylist = [ 0, 2, 4, 6, 8, 8, 10, 12, 14 ]
[Link](8)
print(Mylist)

13) Mylist = [ 0, 2, 4, 6, 8, 8, 10, 12, 14 ]


[Link](2)
[Link](2,4)
[Link](6)
[Link](3)
print(Mylist)

14) Mylist = [ 0, 2, 4, 6, 8, 8, 10, 12, 14 ]


del Mylist
print(Mylist)

15) Mylist = [ 0, 2, 4, 6, 8, 8, 10, 12, 14 ]


[Link]()
print(Mylist)
print("Number of elements in the list is",len(Mylist))

16) l1 = list(range(2,11,2))
print(l1)
l2 = list(range(11))
print(l2)
l3 = list(range(-9,0,2))
print(l3)

17) squares = []
for x in range(1,11):
s = x ** 2
[Link](s)
print (squares)

18) cubes = [ x ** 3 for x in range(1,5) ]


print (cubes)

19) Mymarks = [72,69,80,77,80,90]


print(Mymarks[0])
print([Link](80))
print([Link](80))
..3.. A. PRABHAKAR - 9442979144
[Link]()
print(Mymarks)
[Link]()
print(Mymarks)

20) Mymarks = [72,69,80,77,80,90]


print("1. ", Mymarks[5])
print("2. ", max(Mymarks))
print("3. ", min(Mymarks))
print("4. ", Mymarks)
print("5. ", sum(Mymarks))
print("1 - is my computer mark\n2 - is my highest mark\n
3 - is lowest mark and\n4 - is my marks of first revision
\n5 - is my total mark")

21) divBy4=[ ]
for i in range(21):
if (i%4==0):
[Link](i)
print(divBy4)

22) Can you guess what are a, b and c in the following snippet? / பின்வரும்
குைியீட்டில் a, b மற்றும் c ஆகியன என்ன என்று உங்களால் யூகிக்க முடிகிைதா?

a=[4]
b=(4)
c=(4,)

23) a=[4]
b=(4)
c=(4,)
print("The value of a is",a,"and its type is",type(a))
print("The value of b is",b,"and its type is",type(b))
print("The value of c is",c,"and its type is",type(c))

24) Mymarks = (72,69,80,77,80,90)


print("My language marks are",Mymarks[:2])
print("My subject marks are",Mymarks[2:])
print("My top mark is",max(Mymarks))

..4.. A. PRABHAKAR - 9442979144


25) num=[10,20,30,40,50]
num[2]=35
print(num)

26) num=(10,20,30,40,50)
num[2]=35
print(num)

27) (a, b, c) = (34, 90, 76)


print(a,b,c)
(x, y, z) = (a*2, b/3, c+4)
print(x,y,z)
(p, q, r,s) = (2*2, 2**2, 3*2, 3**3)
print(p, q, r,s)

28) Toppers = (("Vinodini", "XII-F", 98.7), ("Soundarya", "XII-H", 97.5),


("Tharani", "XII-F", 95.3), ("Saisri", "XII-G", 93.8))
print(Toppers[0])
print(Toppers[1][0])
print(Toppers[2])
print(Toppers[0][0], Toppers[1][1], Toppers[2][2])
print("Check the difference of the following outputs:")
print(Toppers)
for i in Toppers:
print(i)

29) setA = {3,6,9}


setB = {1,3,9}
print("1. Union :",setA|setB)
print("2. Intersection :", [Link](setB))
print("3. Difference :",[Link](setB))
print("4. Symmetric difference :", setA^setB)

30) Match / பபொருத்துக.


1. Union : (a) – (minus)
2. Intersection : (b) | (pipeline)
3. Difference : (c) ^ (caret)
4. Symmetric difference: (d) & (ampersand)

..5.. A. PRABHAKAR - 9442979144


31) Dict_Stud = { 'RollNo': '1234', 'Name':'Murali', 'Class':'XII',
'Marks':'451'}
print(Dict_Stud)
print("My name and marks are")
print(Dict_Stud['Name'])
print(Dict_Stud['Marks'])

32) Dict1 = { x : 2 * x for x in range(1,5)}


print(Dict1)
Dict2 = { x : x ** 2 for x in range(1,5)}
print(Dict2)
Dict3 = { x : x ** 3 for x in range(1,5)}
print(Dict3)

33) a=[x**2 for x in range(5)]


b=tuple(a)
c={x**2 for x in range(5)}
print(a)
print(b)
print(c)

Wish You All The Best!

..6.. A. PRABHAKAR - 9442979144

You might also like