Question: DONE USING PYTHON. 1. TASK 1 Write a function fact(n) that calculates the factorial n ! of an input natural number n. 2. TASK 2

DONE USING PYTHON.
1. TASK 1 Write a function fact(n) that calculates the factorial n ! of an input natural number n. 2. TASK 2 Write a function powTwo(x) that calculates 2 to the power of x for any number x 3. TASK 3 Write a decorator called commute which takes as input two functions f and g, and returns the commutator fg - gf. So, when applied to a variable x, commute(f,g)(x) should return f(g(x)) - g(f(x)). 4. TASK 4 Test your decorator by calculating commute(fact,powTwo)(5) commute(powTwo,fact)(6) and report both of these answers
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
