1
2
3
4
5
6
7
8
9
10
11
12
To practice on your own, or to check code you believe shouldn't have been scored as incorrect, go to Trinket.
Post a review on Amazon for the paperback or the Kindle edition.
Email me to give me a compliment, complaint, or correction. I'll respond.
0,1,2,3,4,5,6,7,8,9,10,11
0
0
0
0
In the following code, the first argument is a _____________ argument. | give_greeting("Hello there", first_name="Al") | positional | ^ *positional *$ |
In the following code, the second argument is a _____________ argument. | give_greeting("Hello there", first_name="Al") | keyword | ^ *keyword *$ |
Call the function concat, providing two positional arguments, x and y. | concat(x, y) | concat`(`x`, `y`) | |
Call the function calc, providing x, a positional argument, and a keyword argument. The key is y, the value is 0. | calc(x, y = 0) | calc(x, y = 0) | |
Call a function, providing a positional argument first and then a keyword argument. The values of both arguments are variables. Make everything up. | calc(multiplier, num = chosen_num) | ^ *[a-zA-Z_][a-zA-Z0-9_]*\([a-zA-Z_][a-zA-Z0-9_]*, [a-zA-Z_][a-zA-Z0-9_]* = [a-zA-Z_][a-zA-Z0-9_]*\) *$ | |
Here is the first line of a function and the code that calls it. Rewrite the calling code so it's legal. | def calc(first_number, second_number): calc(second_number = 10, 8) |
calc(8, second_number = 10) The positional argument has to line up with the positional parameter. |
^ *calc\(8, second_number = 10\) *$ |
Call this function. Override the default. Make up the strings. | def combine(first_name, last_name = "Jones"): | combine("Tom", last_name = "Smith") | ^ *combine\(•.+•, last_name = •.+•\) *$ |
Call the function name_the_star. The key is star. The value is the value matching "Justified" in the shows dictionary. | name_the_star(star = shows["Justified"]) | ^ *name_the_star\(star = shows\[•Justified•\]\) *$ | |
Code the first line of a function. The first two parameters are positional, the third parameter is a keyword parameter with a default. The default is an integer. Make everything up. | def a(b, c, d = 9): | ^ *def [a-zA-Z_][a-zA-Z0-9_]*\([a-zA-Z_][a-zA-Z0-9_]*, [a-zA-Z_][a-zA-Z0-9_]*, [a-zA-Z_][a-zA-Z0-9_]* = -?[0-9]+\): *$ | |
Code a function call. The first and second arguments are positional arguments. The third and fourth arguments are keyword arguments. All values are variables. Make everything up. | a(b, c, d = e, f = h) | ^ *[a-zA-Z_][a-zA-Z0-9_]*\([a-zA-Z_][a-zA-Z0-9_]*, [a-zA-Z_][a-zA-Z0-9_]*, [a-zA-Z_][a-zA-Z0-9_]* = [a-zA-Z_][a-zA-Z0-9_]*, [a-zA-Z_][a-zA-Z0-9_]* = [a-zA-Z_][a-zA-Z0-9_]*\) *$ | |
|
962c97e6c8 | ||
|
f5704cbf54 |