0% found this document useful (0 votes)
4 views1 page

Python Functions Practice Exercises

The document presents 20 exercises designed to practice Python functions. Each exercise requires writing a function to solve a specific problem, such as calculating the square of a number, checking for prime numbers, or determining if a year is a leap year. The exercises cover a variety of topics, including math, string manipulation, and list operations.

Uploaded by

binass.power
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Python Functions Practice Exercises

The document presents 20 exercises designed to practice Python functions. Each exercise requires writing a function to solve a specific problem, such as calculating the square of a number, checking for prime numbers, or determining if a year is a leap year. The exercises cover a variety of topics, including math, string manipulation, and list operations.

Uploaded by

binass.power
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Python Functions - 20 Exercises

Below are 20 exercises to practice Python functions. Write your own solutions for each problem
using functions.

1. Write a function to return the square of a number.

2. Write a function that adds two numbers.

3. Write a function to check if a number is even.

4. Write a function that returns the largest number from a list.

5. Write a function to compute factorial of a number.

6. Write a function to reverse a string.

7. Write a function to check if a string is a palindrome.

8. Write a function to find the sum of elements in a list.

9. Write a function to count vowels in a string.

10. Write a function that checks if a number is prime.

11. Write a function to generate Fibonacci series up to n terms.

12. Write a function to convert Celsius to Fahrenheit.

13. Write a function to calculate the area of a circle.

14. Write a function that returns the minimum number from a list.

15. Write a function to concatenate two strings.

16. Write a function that finds the GCD (greatest common divisor) of two numbers.

17. Write a function that accepts a list and returns it in sorted order.

18. Write a function to count the number of words in a string.

19. Write a function that accepts a number and returns the sum of its digits.

20. Write a function to check if a given year is a leap year.

You might also like