Programs Based On Functions - Practical
Programs Based On Functions - Practical
1. Write a program in Python to find factorial for the given number using user
defined function
2. Write a Menu driven program to find the area of Circle, Rectangle and
Triangle using function.
3. Writer a Menu Driven program to perform arithmetic operations((+,-,*, /,%)
using functions.
4. Write a program to display the prime no’s in a given range using functions.
5. Write a program using function to find the HCF of numbers present in the
list(solution below)
6. Write a user defined function in Python named showGrades(S) which takes
the dictionary S as an argument.
The dictionary S contains Name : [Phy,Chem,Maths] as key:value pairs .
The function displays the corresponding grade obtained by the students
according to the following grading rules:
7. Write a user defined function in Python named Puzzle(W,N) which takes the
arguement W as an English word and N as an integer and returns the string
where every Nth alphabet of the word W is replaced with an underscore("_")
For example: if W contains the word "TELEVISION" and N is 3, then the
function should return the string "TE_EV_SI_N" . Likewise for the word
"TELEVISION" if N is 4, then the function should return "TEL_VIS_ON"
8. Write a function LIST_IND(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 that are divisible by 3.
For example: If L contains [12,4,0,11,0,51]
The indexList will have - [0,5]
Solutions:
5.