Page 6 - HA
P. 6

Home Assignment


               E) Answer the following questions:


                   1.  WAP to input a number pass it to a function Factorial, which finds and prints factorial in the
                       function itself.

                   2.  WAP to input how many number of terms of a Fibonacci series, pass it to a function
                       Fibonacci, which returns list of those many Fibonacci numbers, print it in the function.

                   3.  WAP to print N number of multiples of a number X through a function Multiple(X, N). Read X
                       and N from the user.

                   4.  WAP to read a string, pass it to a function VowelCount(), which counts and returns the
                       number of vowels in the string, then print the number of vowels.
                   5.  Given the dictionary x = {‘k1’:’v1’,’k2’:’v2’,’k3’:’v3’}, create a dictionary with the opposite
                       mapping , i.e., write a program to create the dictionary, pass it to a function inverted_D(D)
                       which returns the invert of the dictionary (e.g.{‘v1’:’k1’,’v2’:’k2’,’v3:’k3’}), then print the
                       inverted dictionary.
                   6.  Program to write a program which finds area and perimeter of a rectangle and square.
                       Define two functions in program one for rectangle and other for square, pass values for
                       parameter, both functions should return area and perimeter. Print outside function.
                   7.  Program to input two numbers to a function HCF_LCM(X, Y) which finds and returns gcd/hcf
                       and lcm of two numbers.
                   8.  Program to convert decimal to binary through function.

                   9.  Program to convert binary to decimal through function.
                   10. WAP to input a string, pass it to a function, which counts and returns number of vowels,
                       digits, number of lowercase and uppercase alphabets, then print it.
                   11. Differentiate parameter and argument. Explain the same taking an example in Python.

                   12. Differentiate positional, default and keyword argument. Explain the same taking an example
                       in Python.
                   13. WAP to find roots of the quadratic equation. Write program by taking a function, pass values
                       for a,b,c and the function should return both the roots. Print the roots.
                   14. WAP to search for a value in the given list using binary search method. Define a user defined
                       function BinarySearch(), function should receive the list and value to be searched as
                       argument and return 1 if the value is found 0 otherwise. Print conclusion as per 1/0.

                   15. What do you understand by local and global scope of variables? How can you access a global
                       variable inside the function, if function has a variable with same name?
                   16. Discuss namespace and its type in Python.
                   17. What is LEGB rule? Discuss its use in Python.

                   18. Explain the update in the value of global variable with respect to mutable and immutable
                       data types.

                   19. WAP containing a user defined function which accepts two integer list as parameter and
                       returns a list containing common elements of both the list. Print the resultant list.
   1   2   3   4   5   6