In this lab you will implement four pure functions that transform and analyse data. Each function must be self-contained โ no side effects, no global state.
Functions to Implement
1. celsius_to_fahrenheit(c)
Convert a Celsius temperature to Fahrenheit. Formula: F = C ร 9/5 + 32
2. is_palindrome(s)
Return True if the string s reads the same forwards and backwards, ignoring case and non-alphanumeric characters. For example: "A man a plan a canal Panama" is a palindrome.
3. flatten(lst)
Recursively flatten a deeply nested list into a single flat list. For example:
[1, [2, [3, 4], 5], [6, 7]] โ [1, 2, 3, 4, 5, 6, 7]
4. group_by(lst, key_fn)
Group the items in lst into a dict where each key is the result of applying key_fn to an item, and each value is a list of all items that map to that key. Preserve insertion order within each group.
Output Format
Your program must print exactly:
Tips
For is_palindrome, use s.isalnum() to filter characters and .lower() to normalise
For flatten, check isinstance(item, list) to decide whether to recurse
For group_by, use setdefault or check membership before appending