1. The while loop is a ------------ type of loop.
a) Pretest
b) Post-test
c) Prequalified
d) None of The Above
2. The += operator is an example of a(n) ------------ operator.
a) Relational assignment
b) Complex assignment
c) Augmented assignment
d) None of The Above
3. The ------------ statement causes one or more statements to execute only when a Boolean
expression is ------------.
a) Else, false
b) If, true
c) If, false
d) None of The Above
4. This is a number that identifies an item in a list.
a) Index
b) Element
c) Identifier
d) None of The Above
5. Which of these have highest precedence?
a) *
b) /
c) **
d) None of The Above
6. Select the output of the following code: print('h', '-', 'r', 'u', sep='-')
a) h---r-u
b) h--r-u
c) h-r-u
d) None of The Above
7. If A = 18 and B = 14, evaluate the following expression: A\ \%\ B\ //\ 16
a) 0.25
b) 0
c) 1
d) None of The Above
8. What is the output of the following expression: print(7 / (4 + 3.0))
a) 1
b) 1.0
c) Error
d) None of The Above
9. In the expression 12 + 7 the values on the right and left of the + symbol are called
------------.
a) Operators
b) Operands
c) Math expressions
d) None of The Above
10. A logical design that controls the order in which a set of statements execute is called a
----.
a) Control structure
b) Logical structure
c) Sequence structure
d) None of The Above
11. What is the value of the following expression: 24%6%3, 26//3//3
a) (0,2)
b) (0,3)
c) (1,2)
d) None of The Above
12. When a program compares characters, it actually compares the ------------ codes.
a) Binary
b) ASCII
c) Numeric
d) None of The Above
13. What is the value of num if: num = list(range(0, 6, 2))
a) [0, 2, 4]
b) [0, 2, 4, 6]
c) [0, 6, 2]
d) None of The Above
14. Which of the following Boolean expressions is NOT logically equivalent to the other
three?
a) not(-7>=0 and -7<=12)
b) not(-7<0 or -7>12)
c) not(-7>12 or -7==12)
d) not(-7<12 or -7==12)
15. A ------------ is a Boolean variable that signals when some condition exists in the
program.
a) Signal
b) Sentinel
c) Flag
d) None of The Above
16. A(n) ------------ program translates a high-level language program into a separate
machine language program.
a) Assembler
b) Compiler
c) Translator
d) None of The Above
17. Computers can only execute programs that are written in ------------.
a) Assembly language
b) Pseudocode
c) Machine language
d) None of The Above
18. Which of the following is a count-controlled loop?
a) While
b) Do-while
c) For
d) None of The Above
19. The rules that must be followed when writing a program are called ------------.
a) Syntax
b) Operators
c) Key words
d) None of The Above
20. A variable used to calculate the number of iterations of a loop is called a(n) ------------.
a) Incrementor
b) Counter
c) Controller
d) None of The Above
21. What is the value of X if: L=[2, 4, 6, 8] and X = L[ L[2] // 2 - L[1] ]
a) 2
b) 0
c) 8
d) None of The Above
22. This is the last index in a list.
a) 0
b) List size
c) List size - 1
d) None of The Above
23. This will happen if you try to use an index that is out of range for a list.
a) Nothing
b) Syntax Error
c) IndexError
d) None of The Above
24. Suppose listExample is ['h','e','l','l','o'], what is len(listExample)?
a) 5
b) 4
c) Error
d) None of The Above
25. Suppose list = [2, 33, 222, 14, 7], What is value of list[1:4:2] ?
a) [2, 222]
b) [33, 14]
c) [7]
d) None of The Above
26. Suppose numList is [3, 2, 1], What is (numList * 2) ?
a) [9, 6, 3]
b) [3, 2, 1], [3, 2, 1]
c) [3, 2, 1, 3, 2, 1]
d) None of The Above
27. This symbol marks the beginning of a comment in Python.
a) ||
b) //
c) #
d) None of The Above
28. If L1 =[1, 2, 3] and L2=[3, 2, 1] then L1 + L2 = ...................
a) [4, 4, 4]
b) [1, 2, 3, 2, 1]
c) [1, 2, 3], [3, 2, 1]
d) None of The Above
29. Which of the following operators has its associativity from right to left?
a) %
b) ++
c) **
d) None of The Above
30. Which of the following is a python keyword?
a) Else
b) Whil
c) Prints
d) None of The Above
31. What is the value of the expression: float(7 + int(13.5)%3)
a) 8.0
b) 8
c) Error
d) None of The Above
32. You use a(n) ------------ statement to write a dual alternative decision structure.
a) If statement
b) If-else statement
c) If-call statement
d) None of The Above
33. A compound Boolean expression created with the ------------ operator is true if either
one of its subexpressions is true.
a) Or
b) Not
c) And
d) None of The Above
34. What is the value of the expression: 3 + 4 ** 2 // 12
a) 0
b) 4
c) 3
d) None of The Above
35. What is The value of X if: X = 3 + 9 * ((4 * 11) - 4)/10
a) 39.0
b) 35.0
c) 35
d) None of The Above
36. What is the output of the following?
For i in range(0):
Print(i)
a) No output
b) Error
c) 0
d) None of the above
37. What is the output of the following?
for i in range(2.0):
print(i)
a) 0.0 1.0
b) Error
c) 0 1
d) None of the above
38. What is the output of the following?
X = ‘abcd’
For i in range(len(x)):
X = ‘a’
Print(x)
a) a a a a
b) abcd abcd abcd abcd
c) Error
d) None of the above
39. What is the output of the following?
X = ‘aaaa’
For i in range(len(x)):
Print(x, end=’ ‘)
X = ‘a’
a) aaaaaaa
b) aaaa aaaa aaaa aaaa
c) aaaa a a a
d) None of the above
40. What is the output of the following code?
I=4
While True:
If i%3 == 0:
Print(i)
I -= 2
a) 4 2
b) 4
c) 4 2 0 -1 ………
d) None of the above
41. What is the output of the following?
If (9 < 0) and (0 < -9):
Print(“hello”)
Elif (9 > 0) or False:
Print(“good”)
Elif:
Print(“bad”)
a) bad
b) hello
c) good
d) Error
42. What is the output of the following?
X = “abcdef”
I = “c”
While i in x:
Print(i, end=” “)
a) No Output
b) c c c c c c c …..
c) a b c d e f
d) None of the above
43. What is the output of the following?
X = “abcdef”
I = “a”
While i in x:
Print(i, end=” “)
a) No Output
b) i i i i i i i i i .....
c) a b c d e f
d) None of the above
44. Which numbers are printed?
for i in range(3):
print(i-1)
for i in range(3, 3):
print(i+1)
a) -1, 0, 1
b) 0, 1, 2, 3
c) 1, 0, 1, 1
d) None of the above
45. What is the output of the following code?
False = True
While False:
Print(True)
Break
a) True
b) None
c) Error
d) None of the above
46. What is the value in res:
num1 = 30
num2 = 60
res = (num1 + num2) // 4
a) 22.5
b) 22
c) 22.0
d) None of the above
47. What gets printed?
Numbers = [1, 2, 3, 4, 5, 6, 7, 8]
Print(numbers[-6:6])
a) [3, 4, 5, 6]
b) [3, 4, 5, 6, 7]
c) Error
d) None of the above
48. What is the value of x if: x = int(35.45 + 3/3 – 0.5)
a) 15.38
b) 35
c) Error
d) None of the above
49. What is the output of this expression: 4 * 1 ** 2
a) 4
b) 16
c) Error
d) None of the above
Question 2: True or False (5 Marks) (Please choose a) for True or e) for False)
50. The statement print(‘G’, ‘J’, ‘P’, ‘R’, end=’@’) will display GJPR@ on screen.
a) True
e) False