Build a Student Profile
Python
25 pts
Build a Student Profile
Write two functions:
build_profile(name, **details)returns a dictionary that contains the key"name"plus every keyword argument. For examplebuild_profile("Selam", city="Asmara", age=16)returns{'name': 'Selam', 'city': 'Asmara', 'age': 16}.count_args(*args, **kwargs)returns a tuple: (number of positional arguments, number of keyword arguments). For examplecount_args(1, 2, x=3)returns(2, 1).
Then run the two given print() lines. Expected output:
{'name': 'Selam', 'city': 'Asmara', 'age': 16}
(2, 1)
Checklist
- Define the two functions
build_profileandcount_args. - Make
build_profilereturn a dictionary with the key"name"plus every keyword argument. - Make
count_argsreturn a tuple: the number of positional arguments and the number of keyword arguments. - Run the two given
print()lines.
🔑 Solution
If you view the solution before passing, you earn half points for this exercise. You still need to type it and press Check to finish.
How it works, step by step
Point at a step to highlight its lines. Type the solution yourself and press Check answer to finish.
