You are on page 1of 2

OMSAKTHI

G B PUBLIC SCHOOL
DEPARTMENT OF COMPUTER SCIENCE
COMPUTER SCIENCE (083)-ASSIGNMENT 04
LIST MANIPULATION-CODING

1. Write definition of a method/function 26


DoubletheOdd(Nums) to add and display twice 32
of odd values from the list of Nums. 5. Write a method in python to display the
For example : elements of list thrice if it is a number and
If the Nums contains [25, 24, 35, 20, 32, 41] display the element terminated with ‘#’ if it is
The function should display not a number. 2
Twice of Odd Sum: 202 For example, if the content of list is as follows :
2. Write definition of a method/function ThisList=[‘41’,‘DROND’,‘GIRIRAJ’, ‘13’,‘ZARA’]
FindOut(Names, HisName) to search for The output should be
HisName string from a list Names, and display 414141
the position of its presence. DROND#
For example : GIRIRAJ#
If the Names contain ["Arun", 131313
"Raj","Tarun","Kanika"] ZARA#
and HisName contains "Tarun" 6. Write a method in python to display the
The function should display elements of list twice, if it is a number and
Tarun at 2 display the element terminated with ‘*’ if it is
3. Write a Python method/function not a number. 2
SwitchOver(Val) to swap the even and odd For example, if the content of list is as follows :
positions of the values in the list Val. 2 MyList=['RAMAN','21','YOGRAJ','3','TARA']
Note : Assuming that the list has even number The output should be
of values in it. RAMAN*
For example : 2121
If the list Numbers contain YOGRAJ*
[25, 17, 19, 13,12, 15] 33
After swapping the list content should be TARA*
displayed as 7. Kritika was asked to accept a list of even
[17, 25, 13, 19, 15, 12] numbers but she did not put the relevant
4. Write a Python method/function condition while accepting the list of numbers.
Count(Start,End,Step) to display natural You are required to write a code to convert all
numbers from Start. 2 the odd numbers into even by multiplying
End in equal intervals of Step them by 2.
For example : 8. Write the definition of a function Change(P,N)
If the values of Start as 14, End as 35 and Step to change all the multiples of 10 in the list to
as 6 10and rest of the elements as 1. For example, if
The method should be displayed as the list contains
14 [100,43,20,56,32,91,80,40,45,21]. The function
20 should change the list as
[10,1,10,1,1,1,10,10,1,1] Example:
9. Write a code for function EvenOdd(T, C) to add If the list of nine elements initially contains the
1 in all the odd values and 2 in all the even elements as [4, 2,
values of the list T. 5, 1, 6, 7, 8, 12, 10]
Example: If the original content of list is Then the function should rearrange the list as
[35, 12, 16, 69, 26] [10,12, 8, 7, 6, 1, 5, 2, 4]
The modified content will be: 15. Write a function to swap the elements of every
[36, 14, 18, 70, 28] even location with its following odd location.
10. Write code for a function void ChangOver(P,N) Example :
to repositions all the elements of the list by If a list of nine elements initially contains the
shifting each of them to the next position and elements as
by shifting the last element to the first position. [2,4,1,6,5,7,9,23,10]
For example: if the content of list is then the function should rearrange the array as
[12, 15, 17, 13, 21] [4,2,6,1,7,5,23,9,10]
The changed content will be 16. Write function to replaces elements having odd
[21, 12, 15, 17, 13] values with thrice its value and elements
11. Write a function SWAP2BEST (ARR, Size) to having even values with
modify the content of the list in such a way that twice its value.
the elements, which are multiples of 10 swap Example : if a list of five elements initially
with the value present in the very next position contains elements
in the list. as 3, 4, 5, 16, 9
For example: The the function should rearrange the content
If the content of list ARR is of the list as
[90, 56, 45, 20, 34, 54] 9, 8, 75, 32, 27
The content of list ARR should become 17. Write a function to replaces elements having
[56, 90, 45, 34, 20, 54] even values with its half and elements having
12. Write a function CHANGE( ) in python to divide odd values with twice its value .
all those list elements by 7 which are divisible Example : If a list of five elements initially
by 7 and multiply other-array elements by 3. contains the
Sample Input Data of the list elements as 3, 4, 5, 16, 9
[21,12,35,42,18] then the function should rearrange content of
Content of the list after Calling CHANGE( ) the list as
function 6, 2, 10, 8, 18
[3,36,5,6,54] 18. Define the function SwapArray( )to rearrange
13. Write a function REASSIGN () to divide all the list in such a way that the
those list elements by 5 which are divisible by values of that locations of the array are
5 and multiply other list elements by 2. exchanged.
Sample Input Data of the array (Assume the size of the list to be even).
[20,12,15,60,32] Example :
Content of the list after calling REASSIGN () If the array initially contains [2, 5, 9, 14, 17,8,
function 19, 16]
[4,24,3,12,64] Then after rearrangement the list should
14. Write a function to rearranges the list in contain
reverse. [5, 2, 14, 9, 8, 17, 16, 19]

You might also like