0% found this document useful (0 votes)
3 views3 pages

Function Questions

The document contains a series of programming tasks that require writing Python functions to perform various operations on lists, dictionaries, and strings. Each task specifies the input and expected output, covering topics such as doubling numbers, filtering elements, and manipulating data structures. The functions aim to enhance skills in Python programming and problem-solving.

Uploaded by

sasi
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)
3 views3 pages

Function Questions

The document contains a series of programming tasks that require writing Python functions to perform various operations on lists, dictionaries, and strings. Each task specifies the input and expected output, covering topics such as doubling numbers, filtering elements, and manipulating data structures. The functions aim to enhance skills in Python programming and problem-solving.

Uploaded by

sasi
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

​ ​ ​ ​ ​

FUNCTION RELATED QUESTIONS


1. Write a user defined function DoubleNum( ) to double the multiples of 6 from a
list of integers named Nums and also return its sum. For example : If the list Nums
contains [25,24,35,20,72,41] .The function should display Twice of Sum: 192
[Link] a function Half_List(L), to accept a list L as argument and to return another
list named ‘SList’ that stores the Half of all Non-Zero Elements of L. For example: If
L contains [9,14,0,18,0,6,0] .Then SList will have - [4.5,7.0,9.0,3.0]
[Link] a function double_element() in Python that accepts a list L and a number n.
If the number n exists in the list, it should be updated to its double value. If it does
not exist, print a message saying "Element not found".
[Link] a Python function add_emplyoee() that accepts a dictionary
company_emplyoee, an employee number, a name and department. The function
should add the employee number as key and name, department as value to the
dictionary. If the employee number already exists, print "Employee already exists"
instead of updating it.
[Link] a function countNow (PLACES) in Python, that takes the dictionary,
PLACES as an argument and displays the names (in uppercase) of the places
whose names are longer than 5 [Link] example, Consider the following
dictionary PLACES={1: "Delhi"', 2: "London", 3: "Paris" ,4: "New York", 5: "Doha" }
The output should be:• LONDON
• NEW YORK
6. Write a function, lenWords(STRING), that takes a string as an argument and
returns a tuple containing length of each word of a [Link] example, if the string is
"Come let us have some fun", the tuple will have (4,3, 2, 4, 4, 3)
7. A. Write a python function count_element() to accept a set of negative as well as
positive numbers in a list. Display the sum of negative even numbers and positive
odd numbers available in the list. (Both sum separately).
8. Write a Python function to create a dictionary which accepts months and days
with month as key and days as value. Display the months having 31 days.
9.
10. Write a function INDEX_LIST(L), where L is the list of elements passed as
argument to the function. The function returns another list named ‘indexList’ that
stores the indices of all Non-Zero Elements of [Link] example: If L contains
[12,4,0,11,0,56] The indexList will have - [0,1,3,5]
11. Write a function lenFOURword(L),where L is the list of elements (list of words)
passed as argument to the [Link] function returns another list named
‘indexList’ that stores the indices of all four lettered word of [Link] example:If L
contains [“DINESH”,“RAMESH”, “AMAN”, “SURESH”, “KARN”]The indexList will have
[2, 4]
12. Write a function modilst(L) that accepts a list of numbers as argument and
increases the value of the elements by 10 if the elements are divisible by 5. Also write
a proper call statement for the function. For example: If list L contains [3,5,10,12,15]
Then the modilist() should make the list L as [3,15,20,12,25]
13. Write a function INDEX_LIST(L), where L is the list of elements passed as
argument to the function. The function returns another list named ‘indexList’ that
stores the indices of all NonZeroElements of L. For example: If L contains
[12,4,0,11,0,56] The indexList will have - [0,1,3,5]
14. Write a function SQUARE_LIST(L), where L is the list of elements passed as
argument to the function. The function returns another list named ‘SList’ that stores
the Squares of all Non-Zero Elements of L. For example: If L contains [9,4,0,11,0,6,0]
The SList will have -[81,16,121,36]
15. Write a function Lshift(L), where L is the list of elements passes as an argument
to the function. The function shifts all the elements by one place to the left and then
print it. For example: If L contains [9,4,0,3,11,56] The function will print -
[4,0,3,11,56,9]
16. Write a function in PythonConvert() to replaces elements having even values with
its half and elements having odd values with twice its value in a list. eg:If the list
contains 3,4,5,16,9 then Rearranged list as 6,2,10,8,18
17. Write a function AdjustList(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 2, 15, 3, 14, 7, 9, 19, 6, 1, 10, then after
reversal the list should contain 10, 1, 6, 19, 9, 7, 14, 3, 15, 2
18. Write a function EVEN_LIST(L), where L is the list of elements passed as
argument to the function. The function returns another list named ‘evenList’ that
stores the indices of all even numbers of L. For example: If L contains
[12,4,3,11,13,56] The evenList will have - [12,4,5]
19. Write definition of a method/function DoubletheOdd( ) to add and display twice
of odd values from the list of Nums. For example :If the Nums contains
[25,24,35,20,32,41] The function should display Twice of Odd Sum: 202
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 Array = [40, 50, 60,
100,200, 300]
21. Write a function INDEX_LIST(L), where L is the list of elements passed as
argument to the function. The function returns another list named ‘indexList’ that
stores the indices of all Elements of L which has a even unit place digit. For example:
If L contains [12,4,15,11,9,56] The indexList will have - [0,1,5]
22. Write a function INDEX_LIST(S), where S is a string. The function returns a 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]
23. Write a function chk(k) receive dictionary as argument key as student name and
value as markdisplay student name who score above mark above 90 .If dictionary as
k={‘HARI’:78,’LATHA’:89,’VIRAT’:98,’KOMAL’:90,’YASH’:93}
24. Write a function disp(n) receive List as [[90,87,67],100,[45,84],99,34,[50,60,70]] if
value below 70 remove element from the list and display list.
25. Write a function CRT() receive two parameter such as list and element which is
get from the user before insert element to the list check whether it is divisible by 7
and not by 6.10 elements get from the user.

You might also like