0% found this document useful (0 votes)
60 views2 pages

Worksheet Function First 50

The document contains a worksheet with a series of programming tasks focused on functions in Python. Each task requires writing a specific function that manipulates lists or strings in various ways, such as filtering elements, modifying values, or reversing lists. Examples are provided for each task to illustrate the expected input and output formats.

Uploaded by

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

Worksheet Function First 50

The document contains a worksheet with a series of programming tasks focused on functions in Python. Each task requires writing a specific function that manipulates lists or strings in various ways, such as filtering elements, modifying values, or reversing lists. Examples are provided for each task to illustrate the expected input and output formats.

Uploaded by

itpractical2024
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Worksheet

Working with function

List and Functions 3 Marks important questions

1. Write a function ThreeLetters(L), where L is the list of elements (list of words) passed as
an argument to the function. The function returns another list named ‘l3’ that stores all
three letter words along with its index.
For example:
If L contains [“RAJ”, “ANKIT”, “YUG”, “SHAAN”, “HET”]
The list l3 will have [“RAJ”,0,”YUG”,2,”HET”,4]
2. Write a function modifySal(lst) that accepts a list of numbers as an argument and
increases the value of the elements (basic) by 3% if the elements are divisible by 10. The
new basic must be integer values.
For example:
If list L contains [25000,15130,10135,12146,15030]
Then the modifySal(lst) should make the list L as [25750,15584,10135,12146,15030]
3. Write a function not1digit(li), where li is the list of elements passed as an argument to the
function. The function returns another list that stores the indices of all numbers except 1-
digit elements of li.
For example:
If L contains [22,3,2,19,1,69]
The new list will have – [0,3,5]
4. Write a function shiftLeft(li, n) in Python, which accepts a list li of numbers, and n is a
numeric value by which all elements of the list are shifted to the left.
Sample input data of the list
Numlist= [23, 28, 31, 85, 69, 60, 71], n=3
Output Numlist-[85, 69, 60, 71, 23, 28, 31]
5. Write a function cube_list(lst), where lst is the list of elements passed as an argument to
the function. The function returns another list named ‘cube_List’ that stores the cubes of
all Non-Zero Elements of lst.
For example:
if L contains [2,3,0,5,0,4,0]
The SList will have – [8,27,125,64]
6. Write a function in Python OddEvenTrans(li) to replace elements having even values with
their 25% and elements having odd values with thrice (three times more) of their value in a
list.
For example:
if the list contains [10,8,13,11,4] then
The rearranged list is as [2.5,2,39,33,1]
7. Write a function listReverse(L), where L is a list of integers. The function should reverse
the contents of the list without slicing the list and without using any second list.
Example:
If the list initially contains [79,56,23,28,98,99]
then after reversal the list should contain [99,98,28,23,56,79]
8. Write a function in python named Swap50_50(lst), which accepts a list 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:
l= [8, 9, 7,1,2,3]
Output = [1,2,3,8,9,7]
9. Write a function vowel_Index(S), where S is a string. The function returns a list named ‘il’
that stores the indices of all vowels of S.

For example: If S is “TutorialAICISP”, then index List should be [1,4,6]


10. Write a function NEW_LIST(L), where L is the list of numbers integers and float together. Now
separate integer numbers into another list int_li.
For example:
If L contains [123,34.8, 54.5,0,8.75,19,86.12,56,78,6.6]
The NewList will have [123,0,19,56,78]

You might also like