Advanced Practice with Functions
Now that you know the basics of functions, let’s try some challenging function problems. These tasks will test your logic, return values, and use of multiple parameters.
return carefully!
Create a function that calculates factorial of a number.
Practice loops inside a function and returning results.
factorial(n) that returns the factorial of n.factorial(5) → 120.n.Write a function to check if a word is a palindrome.
Use string operations inside functions.
is_palindrome(word).True if the word is a palindrome, else False.is_palindrome("madam") → True.Create a function that works like a simple calculator.
Understand how to handle multiple parameters and conditions inside a function.
calculator(a, b, operator).+, -, *, /.calculator(10, 5, "*") → 50.Ask for help if you are stuck on:
Good luck! These are tricky but fun 🚀