Buds Public School, Dubai
Computer Science Grade:11-IT STUDENTS
Monthly Exam Revision(Arrays)
1. Write a function getvaluesofodd(x): in python to print sum of odd location values from the given list x
For eg: i/p: x:
10 / 15 / 25 / 3 / 35 / 40o/p s=15+3+40=58
2. Write a function putvaluesofall(first,second): to transfer all the values in to all[]. Here all all[] odd locations should get the values from second[], and even locations should get values from first[].
For eg: i/p first:
10 / 20 / 30Second:
40 / 50 / 60o/P : All:
10 / 40 / 20 / 50 / 30 / 603. Write a function gethalf(m): to exchange the first half values with second half in a given 1 D list x
For eg: i/p: m:
10 / 15 / 25 / 3 / 35 / 40o/p
3 / 35 / 40 / 10 / 15 / 254. Write a function giveswap(a): to swap the values with its next position, whenever the value divisible by 10
For eg: i/p: a:
2 / 10 / 25 / 3 / 13 / 40 / 75o/p
2 / 25 / 10 / 3 / 13 / 75 / 405. Write a function getdata(s): to twice all even values and thrice all odd values
For eg: i/p: s:
2 / 10 / 25 / 3 / 30 / 4 / 5o/p
4 / 20 / 75 / 9 / 60 / 8 / 156. Write a function altenatevalue(a): to print sum of alternate values from given 2D list array
For eg: i/p
10 / 20 / 3040 / 50 / 60
70 / 80 / 90
o/p s=10+30+50+70+90=250
7. Write a function getdiagnol(m): to print only diagnol values from the given 2D list
For eg: i/p
10 / 20 / 3040 / 50 / 60
70 / 80 / 90
o/p 10, 50,90 and 30,50,70
8. Write a function Lower_half(a): to print lowerhalf of the array in 2D list
10 / 20 / 3040 / 50 / 60
70 / 80 / 90
o/p
1040 / 50
70 / 80 / 90
9. Write a function giveproductrow(x): to print sum of each rows of given 2D list
1 / 20 / 4100 / 50 / 0
120 / 1 / 100
o/p : Sum of row 1=1+20+4=25
Sum of of row 2=100+50+0=150
Sum of of Row 3=120+1+100=221
10. Write a function swapcolumn(a): to swap the first column elements with the last column elements in a given 2 D List
For eg: i/p
10 / 20 / 30 / 10040 / 50 / 60 / 200
70 / 80 / 90 / 300
o/p
100 / 20 / 30 / 10200 / 50 / 60 / 40
300 / 80 / 90 / 70
11. Write a function getvaluesofeven(x): in python to print sum of even location values from the given list x
For eg: i/p: x:
10 / 15 / 25 / 3 / 35 / 40o/p s=10+25+35= 70
12. Write a function putvaluesoddeven(all): to transfer all the values from all[] in to odd[] and even[]. Here all all[] odd locations should go to odd[], and even locations should go to even[]
For eg: i/P : All:
10 / 40 / 20 / 50 / 30 / 60o/p even:
10 / 20 / 30odd:
40 / 50 / 6013. Write a function convert(m): to shifting each valu in to its one one position after and shifting last value it to first position
For eg: i/p: m:
10 / 15 / 25 / 3 / 35 / 40o/p
40 / 10 / 15 / 25 / 3 / 3514. Write a function giveswap(a): to swap all even location values with its next odd location value
For eg: i/p: a:
2 / 10 / 25 / 3 / 13 / 40o/p
10 / 2 / 3 / 25 / 40 / 1315. Write a function getdata(s): to divide with 5 the number which are divisible by 5 and multiply other numbers with 3
For eg: i/p: s:
2 / 10 / 25 / 3 / 30 / 4 / 5o/p
6 / 2 / 5 / 9 / 6 / 12 / 116. Write a function tanspose(a): to exchange rows in to columns and columns into rows
For eg: i/p
10 / 20 / 3040 / 50 / 60
70 / 80 / 90
O/p:
10 / 40 / 7020 / 50 / 80
30 / 60 / 90
17. Write a function, getmatvalue(m): to find sum of values , which are divisible by 10 or 3from given 2 D list
For eg: i/p
10 / 4 / 139 / 15 / 200
70 / 55 / 75
o/p s=10+4+200+70=284
18. Write a function getmiddle(x): to print the element of middle row and middle column only
For eg: i/p
10 / 20 / 3040 / 50 / 60
70 / 80 / 90
o/p : Middle row: 40 50 60
Middle column:20 50 80
19. Write a function mataddsub(a,b): to print matrix addition subtraction of given two 2D matrix arrays a[] and b[]
20. Write a function giveshape(a): to do the following format:
For eg: a=[1,2,3,4,5]
o/p: 1 2 3 4 5
1 2 3 4 0
1 2 3 0 0
1 2 0 0 0
1 0 0 0 0