Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

Python function and lib practical

The document outlines various programming tasks in Python focused on creating functions for different purposes, such as calculating factorials, finding the largest number, and computing areas. It also includes tasks for manipulating strings, lists, and tuples, as well as utilizing Python libraries for mathematical operations and random number generation. Each task is accompanied by a placeholder for code and expected output.

Uploaded by

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

Python function and lib practical

The document outlines various programming tasks in Python focused on creating functions for different purposes, such as calculating factorials, finding the largest number, and computing areas. It also includes tasks for manipulating strings, lists, and tuples, as well as utilizing Python libraries for mathematical operations and random number generation. Each task is accompanied by a placeholder for code and expected output.

Uploaded by

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

Python Programming

Functions

1. Write a program to create a function which returns factorial of a number.


CODE:

OUTPUT:

2. Write a program to create a function to find the biggest of two numbers.


CODE:

OUTPUT:

3. Write a program to create a function to calculate the area of a circle, by passing


the radius as argument to the function.
CODE:

OUTPUT:

4. Create a function to calculate the number of uppercase and lowercase letters in a


string.
CODE:

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:

6. Create a function maxtuple () which accepts a tuple as a parameter and returns


the maximum element of the tuple.
CODE:

OUTPUT:
7. Create a function which accepts two numbers as parameters and returns their
sum, product, difference, and quotient.
CODE:

OUTPUT:

8. Create a function to compute the nth Fibonacci number.


CODE:

OUTPUT:

9. Create a function to test if a string is palindrome or not


CODE:

OUTPUT:

10. Write a menu driven program to find the following for given two integers using
function
a. GCD / HCF
b. LCM.
CODE:

OUTPUT:

Using Python Libraries

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:

14. Write a menu driven python program to implement python mathematical


functions.
CODE:

OUTPUT:

15. Write a menu driven python program to implement python string functions
CODE:

OUTPUT:

You might also like