Presentation on theme: "The upper-left corner of a graphics window has the location of: A.0,0 B.200,0 C.0,200 D.200,200."— Presentation transcript:
The upper-left corner of a graphics window has the location of: A.0,0 B.200,0 C.0,200 D.200,200
An object is essentially a more complex variable A.True B.False
Objects are complex data types that contain: A.Only variables B.Only functions C.Both variables and functions
Ask the class What's the difference between the following: – from graphics import * – import graphics
What is the value of student1.id? student1 = Student() student1.id = 5 student2 = student1 student2.id = A.Undefined B.5 C.7 D.Something Else
In Python conditions, *not equals* is written as "/=" True False
Strings are compared by lexographic ordering True False
A single try statement can catch multiple kinds of errors True False
There is usually only one correct solution to a problem involving decision structure True False
The condition x <= y <= z is valid True False
Input validation means prompting a user when input is required True False
A statement that controls the execution of other statements is called A.Boss structure B.Super structure C.Control structure D.Branch
In Python, the body of a decision is indicated by A.Indentation B.Parenthesis C.Curly braces D.A colon
a and (b or c) == (a and b) or (a and c) True False
if a > b: if b > c: print("Spam Please!") else: print("It's a late parrot!") elif b > c: print("Cheese Shoppe") if a >= c: print("Cheddar") elif a < c: print("Gouda") elif c == b: print("Swiss") … else: print("Trees") if a == b: print("Chestnut") else: print("Larch") print("Done") Consider with the following variables: a = 3, b = 5, c = 2
not(a or b) == (not a) or not(b) True False
True or False True False
(True or x) == True True False
(False and x) == False True False
(True or False) == True True False
What does this probably do? obj.set_water_level(5)
What does "self" mean?
"Self is a reference to the calling object." Example: d1.roll() – d1 will be "self"
What method gets called automatically every time we create an instance of a new class?
Where do we declare instance (local) variables in a class?
Why don't we pass a "self" in the following example? class Foo: def __init__(self, bar): self.value = bar f1 = Foo(5) f1.bar(5)
Why shouldn't we directly modify class variables?
Because we might have special functionality in our set_var(self, value): function that will not get called otherwise.
Give an example of a properly named "accessor" method
Give an example of a properly named "mutator" method