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
This is the third line of a class definition. Fill in the blank. | _______last_name = last_name | self. | ^ *self\. *$ |
Code the first line of a class definition. Make up the class name. Remember to start the class name with an uppercase letter. | class Patient(): | ^ *class [A-Z][a-zA-Z0-9_]*\(\): *$ | |
Code the second line of a class definition. The attribute is price. | def __init__(self, price): | def `_`_`init`_`_`(`self`, `price`)`: | |
Code the second line of a class definition. The attribute is area. Don't bother to indent it for this exercise. | def __init__(self, area): | def __init__(self, area): | |
Fill in the blank. | self.last_name = __________ | last_name | ^ *last_name *$ |
Fill in the blank. | def __init__(self, last_name): ____________ = last_name |
self.last_name | ^ *self\.last_name *$ |
Code the next line. Remember to indent it two tabs. | def __init__(self, salary): | self.salary = salary | ^ *self\.salary = salary *$ |
Code the first and second lines of a class definition. Make up the class and attribute names. | class Ocean(): def __init__(self, area): |
^ *class [A-Z][a-zA-Z0-9_]*\(\):\n def __init__\(self, [a-zA-Z_][a-zA-Z0-9_]*\): *$ | |
Code lines 2 and 3 of a class definition. Make up the attribute name. Start by indenting. | def __init__(self, size): self.size = size |
^ *def __init__\(self, ([a-zA-Z_][a-zA-Z0-9_]*)\):\n *self\.\1 = \1 *$ | |
Code a three-line class definition. Make up the class and attribute names. Remember to indent. | class Car(): def __init__(self, price): self.price = price |
^ *class [A-Z][a-zA-Z0-9_]*\(\):\n def __init__\(self, ([a-zA-Z_][a-zA-Z0-9_]*)\):\n self\.\1 = \1 *$ | |
|
682576bc68 | ||
|
de6f18e1ca |