0% found this document useful (0 votes)
9 views

User Defined Functions

Uploaded by

dbmsjava8056
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

User Defined Functions

Uploaded by

dbmsjava8056
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

OXALISS INTERNATIONAL SCHOOL (CBSE)

COMPUTER SCIENCE (083)


WORKSHEET
GRADE : XII CHAPTER : WORKING WITH FUNCTIONS

1. 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 L.
For example: If L contains [12,4,0,11,0,56]
The index List will have - [0,1,3,5]
2. Write a function that receives two string arguments and checks whether they are same-length
strings (returns True in this case otherwise False).

3. Write 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 characters.

For example, Consider the following dictionary

PLACES={1:"Delhi",2:"London",3:"Paris",4:"New York",5:"Doha"}

The output should be:

LONDON

NEW YORK

4. Write a function, lenWords(STRING), that takes a string as an argument and returns a tuple containing
length of each word of a string. For example, if the string is "Come let us have some fun", the tuple will
have (4, 3, 2, 4, 4, 3)

5. Write a program that implements a user defined function that accepts Principal Amount, Rate, Time,
Number of Times the interest is compounded to calculate and displays compound interest. (Hint:
CI=P*(1+r/n)nt)

6. Write a program that contains user defined functions to calculate area, perimeter or surface area
whichever is applicable for various shapes like square, rectangle, triangle, circle and cylinder. The user
defined functions should accept the values for calculation as parameters and the calculated value should
be returned. Import the module and use the appropriate functions.

You might also like