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
When you use positional arguments in a function call, the order of the arguments has to match the order of the ________s in the function. | parameter | ^ *parameter[s]? *$ | |
When you use keyword arguments in a function call, the function's parameters match all the _________ in the function call, not the order of the arguments. | keys | ^ *key[s]? *$ | |
The function call has two arguments. The key in the second argument is second_pet, and the value is "dog". Complete the code. | compare(first_pet = "cat"_________________ | , second_pet = "dog") | , `second_pet `= `"`dog`"`) |
Call the function named calc. The arguments are x, which is 23, and y, which is .4 (that's point 4) | calc(x = 23, y = .4) | calc(x = 23, y = .4) | |
Code the first line of the function that this code is calling. | analyze(nation = "Bangladesh", pop = 163000000) | def analyze(nation, pop): | def analyze\((nation, pop|pop, nation)\): |
Code the first line of a function with one keyword parameter. Then code the function call. The value paired with the key is "Homer". Make up the function name and the key. | def silly_function(character): silly_function(character = "Homer") |
^ *def ([a-zA-Z_][a-zA-Z0-9_]*)\(([a-zA-Z_][a-zA-Z0-9_]*)\):\n\1\(\2 = •Homer•\) *$ | |
Call this function using keyword arguments. Make up the values, which are strings. | def say_hi(greeting, name): print(greeting + ", " + name) |
say_hi(greeting = "Yo", name = "Rocky") | ^ *say_hi\(greeting = •.+•, name = •.+•\) *$ |
Code a function call with two keyword arguments. Use the following variables, not the literal numbers, to represent the values. Make up the function name and the keys. | base = 100 percentage = .015 |
calc(first_arg = base, second_arg = percentage) | ^ *[a-zA-Z_][a-zA-Z0-9_]*\([a-zA-Z_][a-zA-Z0-9_]* = base, [a-zA-Z_][a-zA-Z0-9_]* = percentage\) *$ |
Code a function call with three keyword arguments. The first value is a string. The second value is an integer. The third value is the name of a dictionary. Make everything up. | process_stuff(text = "Result: ", qty = 144, dict = products) | ^ *[a-zA-Z_][a-zA-Z0-9_]*\([a-zA-Z_][a-zA-Z0-9_]* = •.+•, [a-zA-Z_][a-zA-Z0-9_]* = -?[0-9]+, [a-zA-Z_][a-zA-Z0-9_]* = [a-zA-Z_][a-zA-Z0-9_]*\) *$ | |
Code a function call with a single keyword argument. Use the following variable as the value. Make up the function name and the key. | best_guess = -10.3 % 1.98 | calc(num = best_guess) | ^ *[a-zA-Z_][a-zA-Z0-9_]*\([a-zA-Z_][a-zA-Z0-9_]* = best_guess\) *$ |
|
ba20f1fb65 | ||
|
fdc8c094fb |