Download presentation
Presentation is loading. Please wait.
Published byAaron Scott Modified over 11 years ago
1
The upper-left corner of a graphics window has the location of: A.0,0 B.200,0 C.0,200 D.200,200
2
An object is essentially a more complex variable A.True B.False
3
Objects are complex data types that contain: A.Only variables B.Only functions C.Both variables and functions
4
Ask the class What's the difference between the following: – from graphics import * – import graphics
5
What is the value of student1.id? student1 = Student() student1.id = 5 student2 = student1 student2.id = 7 --- A.Undefined B.5 C.7 D.Something Else
6
In Python conditions, *not equals* is written as "/=" True False
7
Strings are compared by lexographic ordering True False
8
A single try statement can catch multiple kinds of errors True False
9
There is usually only one correct solution to a problem involving decision structure True False
10
The condition x <= y <= z is valid True False
11
Input validation means prompting a user when input is required True False
12
A statement that controls the execution of other statements is called A.Boss structure B.Super structure C.Control structure D.Branch
13
In Python, the body of a decision is indicated by A.Indentation B.Parenthesis C.Curly braces D.A colon
14
a and (b or c) == (a and b) or (a and c) True False
15
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
16
not(a or b) == (not a) or not(b) True False
17
True or False True False
18
(True or x) == True True False
19
(False and x) == False True False
20
(True or False) == True True False
21
What does this probably do? obj.set_water_level(5)
22
What does "self" mean?
23
"Self is a reference to the calling object." Example: d1.roll() – d1 will be "self"
24
What method gets called automatically every time we create an instance of a new class?
25
Where do we declare instance (local) variables in a class?
26
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)
27
Why shouldn't we directly modify class variables?
28
Because we might have special functionality in our set_var(self, value): function that will not get called otherwise.
29
Give an example of a properly named "accessor" method
30
get_foo(self):
31
Give an example of a properly named "mutator" method
32
set_foo(self, value):
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.