0% found this document useful (0 votes)
31 views14 pages

2025 2026 Class XII Computer Science Chapter 3 AW

The document outlines several Python functions that perform various list manipulations, including shifting elements, swapping halves, replacing values, counting occurrences, and identifying Armstrong numbers. Each function is described with sample input and expected output. The functions cover a range of operations such as modifying lists based on conditions, calculating sums, and indexing elements.

Uploaded by

snippyjohn24
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)
31 views14 pages

2025 2026 Class XII Computer Science Chapter 3 AW

The document outlines several Python functions that perform various list manipulations, including shifting elements, swapping halves, replacing values, counting occurrences, and identifying Armstrong numbers. Each function is described with sample input and expected output. The functions cover a range of operations such as modifying lists based on conditions, calculating sums, and indexing elements.

Uploaded by

snippyjohn24
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
You are on page 1/ 14

PREDICT THE OUTPUT

PROGRAMS
Write a function LShift(Arr,n) in Python, which accepts a list Arr of numbers and n is a numeric value by
which all elements of the list are shifted to left.
Sample Input Data of the list
Arr= [ 10,20,30,40,12,11], n=2
Output
Arr = [30,40,12,11,10,20]

Write a function in python named SwapHalfList(Array), which accepts a list Array of numbers and swaps the
elements of 1st Half of the list with the 2nd Half of the list ONLY if the sum of 1st Half is greater than 2nd
Half of the list.
Sample Input Data of the list:
Array= [ 100, 200, 300, 40, 50, 60],
Output Arr = [40, 50, 60, 100, 200, 300]

Write a function listchange(Arr) in Python, which accepts a list Arr of numbers,the function will replace the
even number by value 10 and multiply odd number by 5 .
Sample Input Data of the list is:
a=[10, 20, 23, 45]
listchange(a)
output : [10, 10, 115, 225]
Write a function HowMany(ID, VALUE) to count and display number of times the VALUE is present in the list ID. For
example,
if the ID contains [115, 25, 65, 59, 74, 25, 110, 250] and
the VALUE contains 25, the function should print: 25 found 2 times.

Write a function DIVI_LIST() where NUM_LST is a list of numbers passed as argument to the function.The function
returns two list D_2 and D_5 which stores the numbers that are divisible by 2 and 5 respectively from the
NUM_LST.
Example:
NUM_LST=[2,4,6,10,15,12,20]
D_2=[2,4,6,10,12,20]
D_5=[10,15,20]

Write a function Interchange (num) in Python, which accepts a list num of integers,and interchange the adjacent
elements of the list and print the modified list as shown below:
(Number of elements in the list is assumed as even)
Original List:
num = [5,7,9,11,13,15]
After Rearrangement
num = [7,5,11,9,15,13]
Write a function sumcube(L) to test if an element from list L is equal to the sum of the cubes of its digits i.e. it
is an "Armstrong number".Print such numbers in the list.
If L contains [67,153,311,96,370,405,371,955,407]
The function should print 153,370,371,407

Write a function listchange(Arr,n)in Python, which accepts a list Arr of numbers and n is an numeric value
depicting length of the list. Modify the list so that all even numbers doubled and odd number multiply by 3
Sample
Input Data of the list: Arr= [ 10,20,30,40,12,11], n=6
Output: Arr = [20,40,60,80,24,33]
Write a function called letter_freq(my_list) that takes one parameter, a list of strings(mylist) and returns a
dictionary where the keys are the letters from mylist and the values are the number of times that letter appears
in the mylist, e.g.,if the passed list is as:
wlist=list("aaaaabbbbcccdde")
then it should return a dictionary
as{„a‟:5,‟b‟:4,‟c‟:3,‟d‟:2,‟e‟:1}
Write a function in Shift(Lst), Which accept a List „Lst‟ as argument and swaps the elements of every even
location
with its odd location and store in different list eg. if the array initially contains 2, 4, 1, 6, 5, 7, 9, 2, 3, 10
then it should contain 4, 2, 6, 1, 7, 5, 2, 9, 10, 3

Define a function ZeroEnding(SCORES) to add all those values in the list of SCORES, which are ending with
zero (0) and display the sum.
For example :
If the SCORES contain [200, 456, 300, 100, 234, 678]
The sum should be displayed as 600

Write a function INDEX_LIST(L), where L is the list of elements passed as argumentto the function. The
function
returns another list named "indexList" that stores theindices of all Non-Zero Elements of L. For example: If L
contains [12,4,0,11,0,56] The index List will have -[0,1,3,5]

Write a function INDEX_LIST(S), where S is a string. The function returnsa list named indexList„ that stores
the
indices of all vowels of S.For example: If S is "Computer", then indexList should be
[1,4,6]

You might also like