Welcome to your Python practical assessment! This challenge is designed to test your understanding of Python fundamentals, including variables, strings, lists, loops, and dictionaries.
You should have the following two files in your folder:
assessment.py- (EDIT THIS FILE)- This is where you will write your solutions.
- Look for the
# TODOcomments inside the functions.
test_assessment.py- (DO NOT EDIT)- This file contains the automated tests that grade your work.
- Do not modify this file, or the tests may break!
- Open
assessment.pyin your code editor (VS Code, Pycharm, etc.). - You will see empty functions with
passinside them. - Read the Docstring (the text inside
""" """) to understand what the function needs to do. - Replace
passwith your own Python code.
To check if your code is correct, you need to run the test file, not the assessment file.
Make sure your terminal/command prompt is pointing to the folder where these files are saved.
Type the following command and hit Enter:
python test_assessment.pyIf you see FAILED or Error:
Python will tell you exactly which test failed.
-
Example: FAIL: test_cube_number
-
Action: Go back to assessment.py, check your cube_number function, fix the logic, and run the test command again.
If you see OK:
Congratulations! All your functions are correct.
You need to complete the following functions:
-
cube_number: Return a number raised to the power of 3.
-
check_even_or_odd: Use modulo to determine parity.
-
combine_names: Format strings into "Last, First".
-
get_last_item: Retrieve the last item of a list using negative indexing.
-
sum_all_numbers: Calculate the total of a list of numbers.
-
get_country_code: Retrieve values from a dictionary using a key.
Good luck! π