This assessment is designed to help you practice and solidify your understanding of fundamental Python concepts. You will be required to complete a series of functions in the assessment.py file. Your solutions will then be tested using the provided test_assessment.py unittest file.
This assessment focuses on the following Python skills:
- Defining and using Functions (parameters, return values).
- Implementing Basic loops (
for,while). - Processing data (manipulating lists, strings).
- Implementing Basic error handling (
try-except). - Developing Simple algorithms for problem-solving.
assessment.py: This is the file you need to edit. It contains function stubs that you must complete according to their docstrings.test_assessment.py: This file contains unit tests to check if your functions inassessment.pywork correctly. Do not modify this file.README.md: This file, providing instructions.
-
fork the repository to your own GitHub account.
-
Understand the Tasks: Open
assessment.py. Read the docstring for each function carefully. The docstring explains what the function should do, its parameters, and what it should return. -
Implement the Functions: Write the Python code within each function definition in
assessment.pyto meet the requirements described in its docstring. -
Run the Tests: Once you have implemented some or all of the functions, you can test your work. Open your terminal or command prompt, navigate to the directory where you saved these files, and run the following command:
python -m unittest test_assessment.py
Alternatively, if your IDE has a "Run Tests" feature, you might be able to use that.
-
Interpret the Results:
- OK: If all tests pass, you'll see a message like
OK. - FAILURES/ERRORS: If some tests fail,
unittestwill provide details about which tests failed and why. Use this feedback to debug your functions inassessment.py. The test output will show the expected output vs. your function's actual output.
- OK: If all tests pass, you'll see a message like
-
Iterate: Modify your code in
assessment.pybased on the test feedback and re-run the tests until all tests pass.
Good luck!