This module focuses on understanding and utilizing Python modules and packages, as well as practicing namespaces in functions.
- Solution
- Description:
Task "How to Divide?":
- Create two modules,
fake_mathandtrue_math, each containing adividefunction that handles division in different ways.fake_math.divide: Returns an error message when dividing by zero.true_math.divide: Returns infinity when dividing by zero (usingmath.inf).
- Import these functions into a main module using the
askeyword to avoid name conflicts, and test them by passing values, including zero as the divisor.
- Create two modules,
- Solution
- Description:
Task "Function Scope":
- Create a function
test_functionand define an inner functioninner_functionwithin it that prints a message. Callinner_functionwithintest_functionand test whetherinner_functioncan be called outside oftest_function.
- Create a function