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
Fill in the blank to create an instance of the class Customer. Make up the name of the instance. | ______ = Customer("Hedaya") | customer_898 | ^ *[a-zA-Z_][a-zA-Z0-9_]* *$ |
Fill in the blank to create an instance. The value is "blue". | SKU101 = Product_____ | ("blue") | ^ *\(•blue•\) *$ |
Create an instance of this class. The name of the instance is geneva. The value is 144. | class Lake(): def __init__(self, depth): self.depth = depth | geneva = Lake(144) | geneva `= `Lake`(`144`) |
Create an instance of this class. The name of the instance is dog. The value is "canine". | class Animal(): def __init__(self, species): self.species = species | dog = Animal("canine") | dog = Animal("canine") |
Create an instance of this class. Make up the name of the instance and the value. The value can be a string or an integer. | class Student(): def __init__(self, grade): self.grade = grade |
student_id_325 = Student("B+") | ^ *[a-zA-Z_][a-zA-Z0-9_]* = Student\(•.+•|-?[0-9]+\) *$ |
Code the first two lines of a class definition. Make up the class name and attribute name. | class Industry(): def __init__(self, revenue): |
^ *class [A-Z][a-zA-Z0-9_]*\(\):\n def __init__\(self, [a-zA-Z_][a-zA-Z0-9_]*\): *$ | |
Code an instance of this class. The value is a Boolean. Make up the name of the instance. Your choice of Boolean. | class Student(): | student_974 = Student(True) | ^ *[a-zA-Z_][a-zA-Z0-9_]* = Student\(True|False\) *$ |
Code the second and third lines of a class definition. Make up the attribute name. Indent correctly. | def __init__(self, parent): self.parent = parent |
^ *def __init__\(self, ([a-zA-Z_][a-zA-Z0-9_]*)\):\n *self\.\1 = \1 *$ | |
Code an instance of a class. The value is a variable. Make up the name of the instance, the class name, and the variable name. | area12 = Suspect_area(region_3) | ^ *[a-zA-Z_][a-zA-Z0-9_]* = [A-Z][a-zA-Z0-9_]*\([a-zA-Z_][a-zA-Z0-9_]*\) *$ | |
Code a class definition. Then create an instance of it. Make everything up. The value can be a string, number, Boolean, or variable. | class Character(): def __init__(self, motivation): self.motivation = motivation othello = Character("revenge") |
^ *class ([A-Z][a-zA-Z0-9_]*)\(\):\n def __init__\(self, ([a-zA-Z_][a-zA-Z0-9_]*)\):\n self\.\2 = \2\n[a-zA-Z_][a-zA-Z0-9_]* = \1\(•.+•|True|False|-?[0-9]+|[-]?(?:[.]\d+|\d+(?:[.]\d*)?)\) *$ | |
|
f57abaa291 | ||
|
7280f2db9e |