Week9 Tutorial Assignment
Week9 Tutorial Assignment
AND TECHNOLOGY
SCHOOL OF COMPUTING
DEPARTMENT OF COMPUTATIONAL INTELLIGENCE
21CSC203P ADVANCED PROGRAMMING PRACTICE
2.Pure Function: Create a pure function to calculate the area of a circle, given its radius.
Impure Function: Create an impure function to prompt the user for the radius of a circle and print
its area.
3. Pure Function: Create a pure function to find the maximum value in a list of numbers.
Impure Function: Create an impure function to sort a list of numbers in ascending order.
4. Create a function to manage a list of student records, where each record includes name, age, and
grade.
Questions:
1. Mutable Function: Create a mutable function to add a new student to the list of records.
2. Immutable Function: Create an immutable function to find the average age of all students
in the list.
5. Mutable Function: Create a mutable function to update the balance of a bank account.
Immutable Function: Create an immutable function to calculate the interest earned on a bank
account.
6. Anonymous Function: Create an anonymous function to add two numbers and immediately
call it with the values 5 and 3.
Anonymous Function : Create an anonymous function to multiply two numbers and assign it to
a variable. Call the function with the values 4 and 6 and print the result.
7. Anonymous Function: Create an anonymous function to square each element in a list and apply
it to the list [1, 2, 3, 4].
Anonymous Function: Create an anonymous function to filter even numbers from a list and
apply it to the list [1, 2, 3, 4, 5, 6].
8. Map: Create a new list containing the employee names and their corresponding salaries.
Filter: Filter the employees who belong to a specific department.
Reduce: Calculate the average salary for employees in each department.
9. Map: Create a new list containing only the names of the students.
Filter: Filter the students who are above a certain age threshold.
Reduce: Calculate the average grade of all students.