Function Programs
1. Write a function printTable(A) that accepts a number as argument and prints the multiplication table of
that number
2. Write a function DecToBin(N) that accepts decimal number as argument and converts decimal number
to binary number
3. Write a function prodDigits(a) that accepts a number as argument and returns the product of digits of
that number.
4. Write a function sumPdivisors(N) that finds the sum of proper divisors of a number. Proper divisors of a
number are those numbers by which the number is divisible, except the number itself. For example
proper divisors of 36 are 1, 2, 3, 4, 6, 9, 18
5. Write a function printPerfect(x,y) to print all the perfect numbers between x and y. A number is called
perfect if the sum of proper divisors of that number is equal to the number. For example 28 is perfect
number, since 1+2+4+7+14=28.
6. Write a function amicable(a,b) that accepts two number as argument and check the numbers are
amicable pair or not. Two different numbers are called amicable numbers if the sum of the proper
divisors of each is equal to the other number. For example 220 and 284 are amicable numbers.
Sum of proper divisors of 220 = 1+2+4+5+10+11+20+22+44+55+110 = 284
Sum of proper divisors of 284 = 1+2+4+71+142 = 220
7. Write a function filterOdd(A), where L is the list of elements passed as argument to the function. The
function filters odd numbers from the list and stores it to another list and returns it.
8. Write a function SUM_LIST(L), where L is the list of elements passed as argument to the function.
Herewith input are given [5,15,6,1,12,10]. With the help of given inputs you are expected to generate the
following output: The sum_list will have [5, 20, 26, 27, 39, 49]
9. 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 indexList will have - [0,1,3,5]
10. 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
11. 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)
12. Write a function remove_element() in Python that accepts a list L and a number n. If the number n
exists in the list, it should be removed. If it does not exist, print a message saying "Element not found".
13. Write a Python function add_contact(phone_book) that accepts a dictionary phone_book, a name, and a
phone number. The function should add the name and phone number to the dictionary. If the name
already exists, print "Contact already exists" instead of updating it.
14. Write a function dispWord(S) that takes a string as an argument and display the words that start with a
vowel character.
15. Write a function countWords(S ) that takes a string as an argument and count words that end with a
vowel character..