Python function and lib practical
Python function and lib practical
Functions
OUTPUT:
OUTPUT:
OUTPUT:
OUTPUT:
5. Create a function to return the sum and average of the elements in a list by
passing list as argument to function.
CODE:
OUTPUT:
OUTPUT:
7. Create a function which accepts two numbers as parameters and returns their
sum, product, difference, and quotient.
CODE:
OUTPUT:
OUTPUT:
OUTPUT:
10. Write a menu driven program to find the following for given two integers using
function
a. GCD / HCF
b. LCM.
CODE:
OUTPUT:
11. Use math module functions to find the square root, power(4) and to round off a
number(by 3 decimals).
CODE:
OUTPUT:
12. Write a random number generator that generates random numbers between 1
and 6 (simulates dice).
CODE:
OUTPUT:
13. Write a program using string library to encrypt a string by adding ‘@’ character
after each character and create a separate function for decryption.
CODE:
OUTPUT:
OUTPUT:
15. Write a menu driven python program to implement python string functions
CODE:
OUTPUT: