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
Rewrite this function call so it includes 100 as an argument. | add_numbers() | add_numbers(100) | ^ *add_numbers\(100\) *$ |
Rewrite this first line of this function definition so it includes number as a parameter. | def display_number(): | def display_number(number): | ^ *def display_number\(number\): *$ |
Call the function add_numbers, passing 10 and 20 as arguments. | add_numbers(10, 20) | add_numbers`(`10`, `20`) | |
Code the first line of a function definition. The name of the function is greet. The parameter is greeting. | def greet(greeting): | def greet(greeting): | |
Call a function, passing a variable as the argument. Make up the names. | greet(greeting) | ^ *[a-zA-Z_][a-zA-Z0-9_]*\([a-zA-Z_][a-zA-Z0-9_]*\) *$ | |
Code the first line of a function definition that has two parameters. Make everything up. | def add_numbers(first_number, second_number): | ^ *def [a-zA-Z_][a-zA-Z0-9_]*\([a-zA-Z_][a-zA-Z0-9_]*, [a-zA-Z_][a-zA-Z0-9_]*\): *$ | |
In two lines, code a function that displays the sum of its two parameters. Make everything up. | def sum_numbers(first_number, second_number): print(first_number + second_number) |
^ *def [a-zA-Z_][a-zA-Z0-9_]*\(([a-zA-Z_][a-zA-Z0-9_]*), ([a-zA-Z_][a-zA-Z0-9_]*)\):\n print\(\1 \+ \2\) *$ | |
Call a function, passing a variable and a string as arguments. Make everything up. | greet_personally(standard_greeting, "Humberto") | ^ *[a-zA-Z_][a-zA-Z0-9_]*\([a-zA-Z_][a-zA-Z0-9_]*, •.+•\) *$ | |
Code a function that has two parameters. If the values of the two arguments are the same, display "same" | def compare(x, y): if x == y: print("same") |
^ *def [a-zA-Z_][a-zA-Z0-9_]*\(([a-zA-Z_][a-zA-Z0-9_]*), ([a-zA-Z_][a-zA-Z0-9_]*)\):\n if \1 == \2:\n print\(•same•\) *$ | |
Code a function that has three parameters. The first argument is the name of a dictionary. The second and third arguments are a key and a value. The function adds the key and value to the dictionary. Make everything up. | def add_to_dict(dict, key, value): dict[key] = value |
^ *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_]*)\):\n \1\[\2\] = \3 *$ | |
|
1244081e35 | ||
|
139d5e5f21 |