CSC212 Question Bank
CSC212 Question Bank
ARCHIMEDES JR.)
A. Hardware
1.5 One byte has ________ bits.
B. Software
A. 4
C. Operating system
B. 8
D. Application program
C. 12
D. 16
1.2 __________ is the brain of a computer.
A. Hardware
C. 1 billion
1.3 The speed of the CPU may be measured in
D. 1 trillion
__________.
A. megabytes
B. hard disk
D. NIC B. C++
C. Windows XP
A. Hardware
1.14 _____________ is a program that runs on a
B. Software computer to manage and control a computer's
activities.
C. Programs
A. Operating system
D. Keyboards
B. Python
C. Modem
1.11 Computer can execute the code in
____________. D. Interpreter
B. assembly language
A. James Gosling
CSC212 QUESTION BANK (COMPLIED BY LAPORCH AND
ARCHIMEDES JR.)
C. Steve Jobs
A. execute python
1.16 Which of the following statements is true?
B. run python
A. Python 3 is a newer version, but it is backward
compatible with Python 2. C. python
B. C++
1.21 Python syntax is case-sensitive.
C. C
A. True
D. C#
B. False
E. Python
A. Python
A.
B. C++
print("Programming is fun")
C. C
print("Python is fun")
D. Ada
CSC212 QUESTION BANK (COMPLIED BY LAPORCH AND
ARCHIMEDES JR.)
B. A. // comments //
D. /# comments #/
C.
A. syntax
D.
B. runtime
print("Programming is fun)
C. logic
print("Python is fun")
A. A
1.26 In Python, a syntax error is detected by the
B. B ________ at _________.
D. D B. interpreter/at runtime
C. compiler/at runtime
Section 1.7 Programming Style and D. interpreter/at compile time
Documentation
A. //
B. /* I:
C. # print("Programming is fun")
D. $$ print("Python")
print("Computer Science")
II: D. turtle.showturtle()
print("Python")
print("Computer Science") 1.29 To move the turtle to a point at (4, 5), use
___________.
A. turtle.move(4, 5)
III:
B. turtle.moveTo(4, 5)
print("Programming is fun")
C. turtle.moveto(4, 5)
print("Python")
D. turtle.go(4, 5)
print("Computer Science")
E. turtle.goto(4, 5)
IV:
1.30 To draw a circle with radius 50, use
print("Programming is fun") ___________.
print("Python") A. turtle.circle(50)
A. I C. turtle.drawcircle(50)
B. II D. turtle.drawCircle(50)
C. III
A. turtle.penUp()
A. turtle.show()
C. turtle.showDirection() A. turtle.penDown()
CSC212 QUESTION BANK (COMPLIED BY LAPORCH AND
ARCHIMEDES JR.)
B. turtle.pendown()
Chapter 2 Elementary
Programming # Display result
print(average)
C. enter("Enter a string")
A. Python program
2.2 What is the result of eval("1 + 3 * 2")?
B. A Python statement
A. "1 + 3 * 2"
C. Pseudocode
B. 7
D. A flowchart diagram
C. 8
D. "1 + 6"
2.5 If you enter 1 2 3 in one line, when you run
this program, what will happen?
number1 = eval(input())
print("Enter three numbers: ")
number2 = eval(input())
number1 = eval(input())
number3 = eval(input())
number2 = eval(input())
number3 = eval(input())
CSC212 QUESTION BANK (COMPLIED BY LAPORCH AND
ARCHIMEDES JR.)
B. false
# Display result
print(average)
2.9 Which of the following is a valid identifier?
A. The program runs correctly and displays 1.0
A. $343
B. The program runs correctly and displays 2.0
B. mile
C. The program runs correctly and displays 3.0
C. 9X
D. The program runs correctly and displays 4.0
D. 8+9
E. The program will have a runtime error on the
input. E. max_radius
2.6 You can place the line continuation symbol __ 2.10 Which of the following is a valid identifier?
at the end of a line to tell the interpreter that the
statement is continued on the next line. A. import
A. / B. mile1
B. \ C. MILE
C. # D. (red)
D. * E. "red"
E. &
A. true
A. 1
# Display result B. 2
print(average) C. 3
A. 1.0 D. 3.5
C. 3.0
x, y = 1, 2
x=1 x, y = y, x
x=2*x+1 print(x, y)
print(x) A. 1 1
A. 0 B. 2 2
B. 1 C. 1 2
C. 2 D. 2 1
D. 3
A. 1 2
C. 1, 2 B. 1.0 / 2
D. 1, 2, C. 1 // 2
D. 1.0 // 2
D. 37 % 6
2.17 In the expression 45 / 4, the values on the left
and right of the / symbol are called ____.
B. operands A. 1
C. parameters B. 2
D. arguments C. 3
D. 4
A. 10
B. 11 2.22 24 % 5 is _____
C. 11.25 A. 1
D. 12 B. 2
C. 3
A. 0.25E-1
2.24 2 ** 3.0 evaluates to __________.
B. 2.5e-2
A. 9
C. 0.0025E1
B. 8
D. 0.00025E2
C. 9.0
E. 0.0025E+1
D. 8.0
y=1
B. x is 2.
j=i=1 C. x is 3.
i += j + j * 5 D. x is 4.
print("What is i?", i)
B. 1 A. 1 + x = x
C. 5 B. x += 1
D. 6 C. x := 1
E. 7 D. x = x + 1
E. x = 1 + x
x *= x + 1
(A) x -= x + 4
A. x is 1
(B) x = x + 4 - x
B. x is 2
(C) x = x - (x + 4)
C. x is 3
A. (A) and (B) are the same
D. x is 4
B. (A) and (C) are the same
x=2
CSC212 QUESTION BANK (COMPLIED BY LAPORCH AND
ARCHIMEDES JR.)
E. 4
2.40 Which of the following functions cause an
error?
A. 0 B. eval("034")
B. 1 C. int("3.4")
C. 2 D. eval("3.4")
D. -1
E. 3.0
B. 5
A. 1 E. 8
B. 3
D. 7 A. 4
E. 4 B. 5
C. 6
A. 1 E. 8
B. 3
D. 7 A. Yes
E. 4 B. No
A. 3.5 A. 0.0
CSC212 QUESTION BANK (COMPLIED BY LAPORCH AND
ARCHIMEDES JR.)
B. 90.0 B. brackets
C. 45.0 C. single-quotes
D. 30.0 D. double-quotes
E. braces
B. 1.3434343 A. A
C. 3.141592653589793 B. B
D. 5.565656 C. C
D. D
C. 3.141592653589793 A. a
D. 0.5 B. b
C. c
Section 3.3 Strings and Characters D. d
3.10 Which of the following is the correct
expression of character 4?
3.14 Which of the following statement prints
A. 4 smith\exam1\test.txt?
B. "4" A. print("smith\exam1\test.txt")
C. '4' B. print("smith\\exam1\\test.txt")
C. print("smith\"exam1\"test.txt")
A. parentheses
CSC212 QUESTION BANK (COMPLIED BY LAPORCH AND
ARCHIMEDES JR.)
C. print(int(i))
D. 99 A. ABCD
B. A, B, C, D
B. No
3.21 Which of the following statements is correct?
B. 26
Section 3.5 Introduction to Objects and Methods
C. a
3.22 What is the type for object 5.6?
D. z
A. int
B. float
3.19 The expression "Good " + 1 + 2 + 3 evaluates
C. str
to ________.
CSC212 QUESTION BANK (COMPLIED BY LAPORCH AND
ARCHIMEDES JR.)
3.23 Which of the following statements are true? 3.27 The format function returns _______.
A. int B. format("5.3f", x)
C. str D. format("5.3f", x)
D. String
E. bbbb345.354
3.26 Suppose s is "\t\tWelcome\n", what is
s.strip()?
C. \t\tWELCOME\n
print(format("Welcome", "10s"), end = '#')
D. Welcome
print(format(111, "4d"), end = '#')
print(format(924.656, "3.2f"))
CSC212 QUESTION BANK (COMPLIED BY LAPORCH AND
ARCHIMEDES JR.)
A. ???Welcome#?111#924.66
D. Welcome???#?111#924.66 A. turtle.setSize(5)
B. turtle.size(5)
D. Welcome???#111?#????924.66
3.35 To set a turtle drawing speed to 5, use
_________.
D. turtle.dot(10, "red")
D. random.randrange(0, 6)
A. <
D. 2
4.2 The equal comparison operator is
__________.
4.6 random.random() returns ____________.
A. <>
A. a float number i such that 0 < i < 1.0
B. !=
B. a float number i such that 0 <= i < 1.0
C. ==
C. a float number i such that 0 <= i <= 1.0
D. =
D. a float number i such that 0 < i < 2.0
if even = True:
A. x is 0
4.11 Analyze the following code.
B. x is 1
C. x is 2
even = False
D. x is 3
if even:
E. x is 4
print("It is even!")
if y > 0:
elif z > 0:
D. nothing displayed
Code 2:
even = number % 2 == 0
if temperature >= 100: C. Both Code 1 and Code 2 have compile errors.
print("too hot") D. Both Code 1 and Code 2 are correct, but Code
2 is better.
elif temperature <= 40:
print("too cold")
4.15 Suppose income is 4001, what will be
else: displayed by f the following code?
print("just right")
A. none
4.14 Analyze the following code: B. Income is greater than 3000
CSC212 QUESTION BANK (COMPLIED BY LAPORCH AND
ARCHIMEDES JR.)
4.16 Suppose you write the code to display if age < 16:
"Cannot get a driver's license" if age is less than
print("Cannot get a driver's license")
16
elif age == 16:
A. I and II
I: B. II and III
if age < 16: C. I, II, and III
print("Cannot get a driver's license") D. III and IV
if age >= 16: E. All correct
print("Can get a driver's license")
print("Can get a driver's license") Which of the following code is the best?
III: I:
D. (x != 0) or (x = 0)
IV: E. (-10 < x < 0)
if age < 16:
print("Cannot get a driver's license") 4.20 Which of the following is the correct
expression that evaluates to True if the number x
elif age == 16:
is between 1 and 100 or the number is negative?
print("Can get a driver's license")
4.21 Given |x - 2| <= 4, Which of the following is 4.25 Assume x = 4 and y = 5, Which of the
true? following is true?
D. x - 2 <= 4 or x - 2 >= -4 D. x != 5
4.22 Given |x - 2| >= 4, Which of the following is 4.26 Which of the following is equivalent to x !=
true? y?
B. x < 5 or y < 5
print(ch)
A. and, or, *, +
Code 3:
B. *, +, and, or
even = number % 2 == 0
C. *, +, and, or
CSC212 QUESTION BANK (COMPLIED BY LAPORCH AND
ARCHIMEDES JR.)
D. *, +, or, and
True or True and False 5.2 What is the output of the following code?
A. True
B. False x=0
A. (x > 0 and x < 10) is same as (x > 0 and x < 10) x=x+1
E. x is 4
Section 5.2 The while Loop
count = 0
while count < 100: 5.5 What will be displayed when the following
code is executed?
# Point A
print("Welcome to Python!")
number = 6
count += 1
while number > 0:
# Point B
number -= 3
count = 0 sum = 0
B. 0, 1, 2, 3, 4, 5
A: C. 1, 2, 3, 4
print("Welcome to Python")
D. range(4)
C:
B. range(10, 4, -1)
D:
C. range(1, 3, 1)
for count in range(1, 12):
D. range(2.5, 4.5)
print("Welcome to Python")
E. range(1, 2.5, 4.5)
A. BD
B. ABC
5.11 Which of the following loops correctly
C. AC computes 1/2 + 2/3 + 3/4 + ... + 99/100?
D. BC
E. AB A:
sum = 0
sum += i / (i + 1) B. ABCD
C. B
E. CD
B:
sum += i / (i + 1)
for i in range(1, 11):
B. 1 2 3 4 5 6 7 8 9 10
C:
C. 1 2 3 4 5
sum = 0
D. 1 3 5 7 9
for i in range(1.0, 99.0):
E. 2 4 6 8 10
sum += i / (i + 1)
y=0
D:
for i in range(0, 10):
sum = 0
y += i
for i in range(1.0, 100.0):
sum += i / (i + 1)
print(y)
A. 10
print("Sum is", sum)
B. 11
A. BCD
C. 12
CSC212 QUESTION BANK (COMPLIED BY LAPORCH AND
ARCHIMEDES JR.)
D. 13 D. 20
E. 45
C. 11
D. 20
Which of the pattern is produced by the following
code?
5.15 What is the output for y?
for i in range(10, 1, -2): print(j if j <= i else " ", end = " ")
y += i print()
A. Pattern A
print(y) B. Pattern B
A. 10 C. Pattern C
B. 40 D. Pattern D
C. 30
CSC212 QUESTION BANK (COMPLIED BY LAPORCH AND
ARCHIMEDES JR.)
A. 100
sum = d = 0 B. 20
while d != 10.0: C. 10
d += 0.1 D. 45
sum += sum + d
A. The program does not run because sum and d 5.20 How many times is the print statement
are not initialized correctly. executed?
C. 10
5.18 To add 0.01 + 0.02 + ... + 1.00, what order
should you use to add the numbers to get better D. 45
accuracy?
B. add 1.00, 0.99, 0.98, ..., 0.02, 0.01 in this order 5.21 Will the following program terminate?
to a sum variable whose initial value is 0.
balance = 10
Section 5.6 Case Studies
B. 16
sum = 0
C. 17
item = 0
D. 18
while item < 5:
item += 1
5.24 Will the following program terminate?
sum += item
print(sum)
while True:
A. 5
if balance < 9: continue
B. 6
balance = balance - 9
C. 7
A. Yes
D. 8
B. No
item = 0
if number % i == 0:
i += 1
for i in range(1, n):
# iteration
print("i is", i, "isPrime is", isPrime)
A. 2*n
A. i is 5 isPrime is True
B. n
B. i is 5 isPrime is False
C. n - 1
C. i is 6 isPrime is True
D. n + 1
D. i is 6 isPrime is False
print("i is", i)
6.3 A function _________.
A. i is 3 followed by 9 is prime
Sections 6.3 Calling a Function
B. i is 3 followed by 9 is not prime
6.4 Arguments to functions always appear within
C. i is 2 followed by 9 is prime
__________.
D. i is 2 followed by 9 is not prime
A. brackets
A. None
6.5 Does the function call in the following
B. int function cause syntax errors?
C. double
math.sin(math.pi) A. void
B. nothing
main() C. 0
A. Yes D. None
B. No
B. storage area
print(f(5))
C. a stack
D. an array
The missing function body should be ________.
A. return "number"
Sections 6.4 Functions With/Without Return
B. print(number)
Values
C. print("number")
6.7 Which of the following should be defined as a
None function? D. return number
A. Write a function that prints integers from 1 to
100.
Sections 6.5 Positional and Keyword Arguments
B. Write a function that returns a random integer
from 1 to 100. 6.10 Given the following function header:
B. f(p1 = 1, 2, 3, 4) n -= 1
C. f(p1 = 1, p2 = 2, p3 = 3, 4)
E. f(1, 2, 3, p4 = 4) A. aaaaa
B. aaaa
D. invalid call
while n > 0:
n -= 1
print(message)
A. aaaaa n -= 1
B. aaaa
D. invalid call
nPrint("A message", k)
B. 1
while n > 0: D. 3
print(message)
CSC212 QUESTION BANK (COMPLIED BY LAPORCH AND
ARCHIMEDES JR.)
6.14 Given the following function 6.16 A variable defined inside a function is
referred to as __________.
A. a global variable
def nPrint(message, n):
B. a function variable
while n > 0:
C. a block variable
print(message)
D. a local variable
n -= 1
A. a global variable
B. function parameters
Sections 6.6 Passing Parameters by Values
C. global constants
6.15 When you invoke a function with a
parameter, the value of the argument is passed to D. local variables
the parameter. This is referred to as _________.
A. function invocation
6.19 What will be displayed by the following
B. pass by value code?
C. pass by reference
def f1():
print(y)
print(x)
x=1
A. 1 3
def f1():
B. 3 1
x=x+2
C. The program has a runtime error because x is
not defined. print(x)
D. 1 1
E. 3 3 f1()
print(x)
def f1(): D. 1 1
x=3 E. 3 3
print(x)
print(x)
x=1
A. 1 3
def f1():
B. 3 1
global x
C. The program has a runtime error because x is
not defined. x=x+2
D. 1 1 print(x)
E. 3 3
CSC212 QUESTION BANK (COMPLIED BY LAPORCH AND
ARCHIMEDES JR.)
A. 1 3
def f1(x = 1, y = 2):
B. 3 1
x=x+y
C. The program has a runtime error because x is
not defined. y += 1
D. 1 1 print(x, y)
E. 3 3
f1(2, 1)
x=x+y E. 3 3
y += 1
f1()
def f1(x = 1, y = 2):
A. 1 3
x=x+y
B. 3 1
y += 1
C. The program has a runtime error because x
and y are not defined. print(x, y)
D. 1 1
E. 3 3 f1(y = 2, x = 1)
A. 1 3
B. 2 3
CSC212 QUESTION BANK (COMPLIED BY LAPORCH AND
ARCHIMEDES JR.)
A. Bottom-up approach
6.26 Which of the following function headers is
correct? B. Top-down approach
A. A stub
Section 6.11 Returning Multiple Values
B. A function
6.27 What will be displayed by the following
code? C. A function developed using botton-up
approach
x, y = f1(y = 2, x = 1)
Section 7.2 Defining Classes for Objects
print(x, y)
7.1 __________ represents an entity in the real
A. 1 3 world that can be distinctly identified.
B. 3 1 A. A class
7.2 _______ is a template, blueprint, or contract 7.6 The ________ creates an object in the memory
that defines objects of the same type. and invokes __________.
A. program
B. class class A:
D. data self.s = s
B. return
a = A("Welcome")
C. class
a.print()
D. All of the above.
A. The program has an error because class A
does not have a constructor.
7.5 ________ is used to create an object. B. The program has an error because class A
should have a print method with signature
A. A constructor print(self, s).
B. A class C. The program has an error because class A
should have a print method with signature
C. A value-returning method
print(s).
D. A None method
D. The program would run if you change print(s)
to print(self.s).
CSC212 QUESTION BANK (COMPLIED BY LAPORCH AND
ARCHIMEDES JR.)
print(self.s)
a = A()
class A: a.print()
a.print()
7.10 Given the declaration x = Circle(), which of
A. The program has an error because class A
the following statement is most accurate.
does not have a constructor.
A. x contains an int value.
B. The program has an error because s is not
defined in print(s). B. x contains an object of the Circle type.
C. The program runs fine and prints nothing. C. x contains a reference to a Circle object.
D. The program has an error because the D. You can assign an int value to x.
constructor is invoked without an argument.
class A:
class A:
def __init__(self, s = "Welcome"):
def __init__(self):
self.s = s
self.x = 1
self.__y = 1
def print(self):
CSC212 QUESTION BANK (COMPLIED BY LAPORCH AND
ARCHIMEDES JR.)
B. The program has an error because y is private 7.13 Analyze the following code:
and cannot be access outside of the class.
self.__y = 1
def getY(self):
def __init__(self):
self.x = 1 a = A()
self.__y = 1 a.x = 45
print(a.x)
def getY(self):
def A: a = A()
__a = 1 print(a.getX())
A. __a
7.16 Which of the following statement is most
B. __b
accurate?
C. __c__
D. __d__
A. A reference variable is an object.
def __init__(self):
def main(): B. 2
myCount = Count() C. 3
times = 0 D. 4
E. -1
A. P
class Count:
8.3 What is min("Programming is fun")?
def __init__(self):
A. P
self.count = 0
B. r
main()
C. a blank space character
A. count is 101 times is 0
D. u
B. count is 100 times is 0
E. n
C. count is 100 times is 100
C. r
Section 8.2 The str Class
D. pr
8.1 What is len("Good")?
E. pro
A. 1
CSC212 QUESTION BANK (COMPLIED BY LAPORCH AND
ARCHIMEDES JR.)
C. Programming is f
A. Pr E. Programming is
B. P
D. n A. Pr
E. un B. P
C. Pro
A. P E. Programming is
B. r
C. s[1] = 'r'
8.7 What is "Programming is fun"[-3:-1]?
D. print(s.strip())
A. Pr
B. P
8.11 What will be displayed by the following
C. fun code?
D. un
E. fu class Count:
B. 2
s1 = "Good"
C. 3
s2 = "Good"
D. 4
print(id(s1) == id(s2))
E. -1
A. True False
B. True True
8.15 Given a string s = "Programming is fun",
C. False True what is s.rfind('m')?
D. False False A. 8
B. 7
C. 3
8.16 Given a string s = "Programming is fun",
D. 4 what is s.find('m')?
A. 8
D. 4
8.17 Given a string s = "Programming is fun",
E. -1 what is s.startswith('m')?
A. 0
CSC212 QUESTION BANK (COMPLIED BY LAPORCH AND
ARCHIMEDES JR.)
B. 1 E. False
C. -1
E. False A. God
B. Good
C. -1
8.22 Analyze the following code:
D. True
E. False
class Name:
A. 0 self.mi = mi
B. 1 self.lastName = lastName
C. -1
firstName = "Peter"
8.23 Analyze the following code: Section 8.5 Operator Overloading and Special
Methods
B. str(obj)
B. frame = Window()
B. s1 in s2
9.3 How do you create an event loop?
C. s1.contains(s2)
A. window.loop()
D. si.in(s2)
B. window.main()
C. window.mainloop()
8.29 Suppose i is 2 and j is 4, i + j is same as
_________. D. window.eventloop()
A. i.__add(j)
9.6 Assume v1 = IntVar(), how do you set a new 9.9 Assume name = StringVar(), how do you
value 5 to v1. create a text field (entry) under parent frame2
with variable bound to name?
A. v1 = 5
A. entryName = Entry(frame2, textvariable =
B. v1.setValue(5)
name)
C. v1.set(5)
B. entryName = Entry(frame2, variable = name,
D. v1.get(5) value = "")
9.8 Assume v1 = IntVar(), how do you create a 9.11 How do you create a text area?
radio button under parent frame1 with variable
bound to v1 and value 1? A. use Label
9.13 How do you draw a rectangle centered at 9.16 How do you draw a red line from 100, 100 to
100, 100 with width 100 and height 100 on canvas? 400, 500?
A. canvas.create_rect(100, 100, 100, 100) A. canvas.create_line(100, 100, 100, 500, fill =
"red")
B. canvas.create_rectangle(100, 100, 100, 100)
B. canvas.create_line(100, 100, 400, 100, fill =
C. canvas.create_rect(100 - 50, 100 - 50, 100 + 50,
"Red")
100 + 50)
C. canvas.create_line(100, 100, 400, 500, filled =
D. canvas.create_rectangle(100 - 50, 100 - 50, 100
"red")
+ 50, 100 + 50)
D. canvas.create_line(100, 100, 400, 500, fill =
"red")
9.14 How do you draw a circle rectangle centered
at 100, 100 with radius 100 on canvas?
9.17 How do you draw a polygon consisting of
A. canvas.create_oval(100, 100, 100, 100)
points (30, 40), (50, 50), (10, 100) filled with red
B. canvas.create_oval(100 - 100, 100 - 100, 100 + color?
100, 100 + 100)
A. canvas.create_poly(30, 40, 50, 50, 10, 100, fill =
C. canvas.create_oval(100 - 50, 100 - 50, 100 + 50, "red")
100 + 50)
CSC212 QUESTION BANK (COMPLIED BY LAPORCH AND
ARCHIMEDES JR.)
D. canvas.create_polygon((30, 40), (50, 50), (10, 9.21 Which option do you use to put the
100), fill = "red") components in a container using the pack
manager in the same row?
A. component.pack(LEFT)
9.18 How do you display a text "Good morning"
centered at 30, 40 with color red? B. component.pack(side = LEFT)
C. BOTTOM
Section 9.6 The Geometry Managers D. TOP
9.19 _______ are geometry managers in Tkinter.
A. pack 9.23 Using a grid manager, you can use the option
_________ to place a component in multiple rows
B. grid
and columns.
C. place
A. row
D. flow
B. column
C. rowspan
9.20 To place a button in a specified row and
D. columnspan
column in its parent container, use ________.
A. pack manager
Section 9.8 Displaying Images
B. grid manager
CSC212 QUESTION BANK (COMPLIED BY LAPORCH AND
ARCHIMEDES JR.)
B. menu1 = menu(menubar)
B. .gif
9.29 To add a menubar, use __________
C. .bmp
A. window.configure(menu = menubar)
D. .jpg
B. window.config(menubar)
C. window.config(menu = menubar)
9.26 You can display an image in
______________. D. window.configure(menubar)
A. a label
E. an entry B. menu.post()
C. menu.display(300, 300)
B. canvas.bind("<Button-1>", p)
B. <ButtonReleased-2>
9.32 To bind a canvas with a right mouse click
event p, use __________ C. <ButtonReleased-3>
A. canvas.left(p) D. <ButtonPressed-1>
B. canvas.bind("<Button-1>", p) E. <ButtonPressed-2>
C. canvas.bind("Button-1", p)
B. <Double-Button-2>
9.33 To bind a canvas with a mouse entered event
p, use __________ C. <Double-Button-3>
A. canvas.entered(p) D. <Triple-Button-1>
B. canvas.bind("<Enter>", p) E. <Triple-Button-2>
C. canvas.bind("<Entered>", p)
A. canvas.entered(p)
9.34 The event _____________ is fired when the
mouse is moved while the middle mouse is being B. canvas.bind("<Enter>", p)
held down.
C. canvas.bind("<Key>", p)
A. <B1-Motion>
D. canvas.bind(<Enter>, p)
B. <B2-Motion>
E. canvas.bind("<Enter>", p)
C. <B3-Motion>
D. <Button-1>
9.38 The mouse event object has the property
E. <Button-2> ____________.
CSC212 QUESTION BANK (COMPLIED BY LAPORCH AND
ARCHIMEDES JR.)
A. x
B.
9.42 To display an input dialog named "Is this an
tkinter.messagebox.showwarning("showwarning"
integer?", use __________
, "Programming is fun")
A. tkinter.messagebox.showinfo("showinfo", "Is
C. tkinter.messagebox.showerror("showerror",
this an integer?")
"Programming is fun")
B.
D. tkinter.messagebox.askyesno("ashyesno",
tkinter.messagebox.showwarning("showwarning"
"Programming is fun")
, "Is this an integer?")
C. tkinter.messagebox.showerror("showerror",
9.40 To display a warning dialog named "Is this an integer?")
"Variable is assigned, but not used", use
D. tkinter.messagebox.askyesno("ashyesno", "Is
__________
this an integer?")
A. tkinter.messagebox.showinfo("showinfo",
"Variable is assigned, but not used") Chapter 10 Lists
B.
tkinter.messagebox.showwarning("showwarning"
, "Variable is assigned, but not used") Section 10.2 List Basics
C. list1 = list([12, 4, 4]) 10.5 Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what
is min(list1)?
D. list1 = [12, 4, 4]
A. 5
E. list1 = [1, "3", "red"]
B. 4
C. 8
10.2 What is list("abcd")?
D. 25
A. ['a', 'b', 'c', 'd']
E. 1
B. ['ab']
C. ['cd']
10.6 Suppose list1 is [1, 3, 2], what is sum(list1)?
D. ['abcd']
A. 5
B. 4
10.3 Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what
is len(list1)? C. 6
A. 6 D. 2
B. 7 E. 1
C. 8
E. 4 A. list1.shuffle()
B. shuffle(list1)
B. 4
10.8 Suppose list1 is [1, 3, 2, 4, 5, 2, 1, 0], Which of
C. 8 the following is correct?
D. 25 A. print(list1[0])
E. 1 B. print(list1[:2])
C. print(list1[:-2])
CSC212 QUESTION BANK (COMPLIED BY LAPORCH AND
ARCHIMEDES JR.)
10.9 Suppose list1 is [1, 3, 2, 4, 5, 2, 1, 0], What is 10.13 list1 = [11, 2, 23] and list2 = [11, 2, 2], list1 <
list1[-1]? list2 is ________
A. 3 A. True
B. 5 B. False
C. 1
D. 0 10.14 list1 = [11, 2, 23] and list2 = [2, 11, 23], list1
== list2 is ________
A. True
10.10 Suppose list1 is [1, 3, 2, 4, 5, 2, 1, 0], What is
list1[:-1]? B. False
A. 0
C. [1, 3, 2, 4, 5, 2] A. list1.add(5)
D. [1, 3, 2, 4, 5, 2, 1, 0] B. list1.append(5)
C. list1.addLast(5)
A. [2, 6, 4]
C. list1.add(3, 5)
10.12 Suppose list1 = [0.5 * x for x in range(0, 4)],
list1 is ________ D. list1.append(3, 5)
A. [0, 1, 2, 3]
A. 0
B. 4
C. [25, 20, 5, 5, 4, 3, 3, 1]
D. [1, 3, 4, 5, 20, 5, 25, 3] 10.24 Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what
is list1 after list1.pop()?
B. 1
D. ['abcd']
for i in range(0, 6):
B. 6 1 2 3 4 5
myList = [1, 5, 5, 5, 5, 1] C. 2 3 4 5 6 6
max = myList[0] D. 1 1 2 3 4 5
indexOfMax = 0 E. 2 3 4 5 6 1
max = myList[i]
CSC212 QUESTION BANK (COMPLIED BY LAPORCH AND
ARCHIMEDES JR.)
list1 = [1, 3]
list1[0] = 4 v=1
print(list2) values[0] = 44
A. [1, 3]
B. [4, 3] t=3
C. [1, 4] v = [1, 2, 3]
D. [1, 3, 4] f(t, v)
print(t, v[0])
Sections 10.7-10.8 A. 1 1
D. 3 44
def f(values):
values[0] = 44
10.32 What will be displayed by the following
code?
v = [1, 2, 3]
print(v) values.append(i)
B. [1, 2, 3, 44]
C. [44, 2, 3] f(1)
D. [1, 2, 3] f(2)
CSC212 QUESTION BANK (COMPLIED BY LAPORCH AND
ARCHIMEDES JR.)
v = f(3) A. at index 3
print(v) B. at index 4
C. [1, 2, 3]
Chapter 1 25. C
1. A 26. B
2. B 27. D
3. D\ C 28. D
4. B 29. E
5. B 30. A
6. C 31. B
7. E 32. B
9. D Chapter 2
10. B and C 1. A
11. A 2. B
12. A 3. B
13. C 4. C
14. A 5. E
15. D 6. B
16. B 7. A
20. C 11. B
21. A 12. D
22. B 13. D
23. C 14. D
CSC212 QUESTION BANK (COMPLIED BY LAPORCH AND
ARCHIMEDES JR.)
16. B 41. E
17. C CHAPTER 3
18. B 1. D
20. D 3. D
21. E 4. C
22. D 5. E
23. B 6. A
24. D 7. B
25. B 8. C
26. C 9. D
29. D 12. B
30. E 13. C
31. B 14. B
32. D 15. D
34. B 17. B
36. D 19. D
37. A 20. C
38. C 21. B
39. D 22. B
CSC212 QUESTION BANK (COMPLIED BY LAPORCH AND
ARCHIMEDES JR.)
24. C 11. B
25. B 12. D
26. D 13. C
27. C 14. D
28. A 15. B
29. B 16. E
30. D 17. B
31. C 18. C
34. C 21. C
35. A 22. B
36. D 23. B
24. D
Chapter 4 25. D
2. C 27. A
5. C 30. B
6. B 31. C
7. C 32. E
8. B 33. A
24. B
Chapter 5 25. D
1. C 26. B
2. E 27. B
4. E 29. C
5. C
6. B CHAPTER 6
7. D 1. A
8. D 2. B
9. Option B and D 3. B
11. B 5. B
12. B 6. C
13. E 7. A
14. D 8. D
15. C 9. D
17. C 11. B
18. A 12. E
19. A 13. C
20. D 14. C
21. A 15. B
22. B 16. D
23. A 17. A
CSC212 QUESTION BANK (COMPLIED BY LAPORCH AND
ARCHIMEDES JR.)
18. A 12. B
19. B 13. E
20. B 14. B
21. C 15. B
23. E 17. B
24. D CHAPTER 8
25. E 1D
26. C 2D
27. D 3C
28. B 4B
29. A 5D
6D
18 D 12 A
19 D 13 D
20 E 15 B
21 C 16 D
22 B 17 C
23 A 18 A
24 A/D 19 ABC
25 AC 20 B
26 AB 21 B
28 AB 23 C/D
29 B 24 C
30 25 B
CHAPTER 9 26 ABCD
1D 27 A
2 C 28 A
3C 29 C
4B 30 D
5D 31 B
6C 32 E
7C 33 B
8D 34 B
9A 35 C
10 D 36 C
11 C 37 C
CSC212 QUESTION BANK (COMPLIED BY LAPORCH AND
ARCHIMEDES JR.)
38 ABC 19 D
39 A 20 B
40 B 21 E
41 C 22 A
42 D 23 C
24 A
CHAPTER 10 25 A
2A 28 C
3C 29 B
4D 30 C
5E 31 D
6C 32 C
7C 33 D
8 ABCD 34 C
9D 35 A
10 B 36 E
11 C 37 D
12 B
13 B
14 B
15 B
16 A
17 A
18 D