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.