Professional Documents
Culture Documents
Prelim Examination ITELEC3 - ITE ELECTIVE03 (Python Programming)
Prelim Examination ITELEC3 - ITE ELECTIVE03 (Python Programming)
Prelim Examination ITELEC3 - ITE ELECTIVE03 (Python Programming)
SET 02
MATCHING
H 1. What would be the output from the following Python code segment?
for x in range(20,25):
print x
B 2. What would be the output from the following Python code segment?
for i in range(5,10):
print i
A 3. What would be the output from the following Python code segment?
x=1
while x<5:
print x,
x+=1
C 12. e = (a + b) * c / d #( 30 * 15 ) / 5
The value of e is?
H 13. e=b/d*a+c
What is the value of e?
I 14. e=b+d+a+a*c
What is the value of e?
F 15. e=b+d*a+c
What is the value of e?
E_ 16. e = (a * b + a ) * c / d
What is the value of e?
B 17. e=b*d+a/c
print "What is the value of e?", e
G 18. e = (a + b + a ) * c / d
What is the value of e?
D 19. e=b/d+a*c
print "What is the value of e?", e
A 29. What will be printed on-screen after evaluating the following Python code?
intID = 1
if intID == 1:
print "Chester"
elif intID == 2 | intID == 3:
print "Mark"
elif intID == 4:
print "Jhong"
else:
print "Haji"
D 30. What will be printed on-screen after evaluating the following Python code?
intID=3
if intID == 1:
print "Chester"
elif intID == 2 | intID == 3:
print "Mark"
elif intID == 4:
print "Jhong"
else:
print "Haji"
a. strange d. even
b. odd e. mindreader
c. lower f. higher
B 38. What will be printed on-screen after evaluating the following Python code?
guess=5;answer=5
if guess < answer:
print 'higher'
elif guess > answer:
print ' lower'
else: # guess == answer
print 'mindreader!!!'
B 39. What will be printed on-screen after evaluating the following Python code?
number=5
test = number % 2
if test == 0:
print "even"
elif test == 1:
print "odd"
else:
print "strange"
Case Analsysis:
Consider the following sequence of assignment statements:
>>> a = 10
>>> b = 20
>>> a = b
Match the following to the items below.
a. b d. 0
b. 10 e. 30
c. 20
Multiple Choice
Identify the choice that best completes the statement or answers the question.
a. // c. >>>
b. # d. >>
B 47. What is the result of the expression 15//2?
a. 1 c. 7.7
b. 7 d. 30
D 48. Which of the following function convert a String to a list in python?
a. repr(x) c. tuple(s)
b. eval(str) d. list(s)
B 49. Which of the following function convert an integer to an unicode character in python?
a. ord(x) c. oct(x)
b. unichr(x) d. hex(x)
D 50. Which of the following operator in python evaluates to true if it does not finds a variable in the specified sequence and false
otherwise?
a. // c. **
b. is d. not in
Prepared By: