PYTHON Test 2
PYTHON Test 2
26. In python we do not specify types; it is directly interpreted by the compiler, so consider the
following operation to be performed.
1.>>>x = 13 ? 2 objectives is to make sure x has a integer value, select all that apply (python 3.xx)
a) x = 13 // 2
b) x = int(13 / 2)
c) x = 13 % 2
d) All of the mentioned
27. What error occurs when you execute?
apple = mango
a) SyntaxError
b) NameError
c) ValueError
d) TypeError
28. Carefully observe the code and give the answer.
1.def example(a):
2. a = a + '2'
3. a = a*2
4. return a
5.>>>example("hello")
a) indentation Error
b) cannot perform mathematical operation on strings
c) hello2
d) hello2hello2
29. What dataype is the object below ?
L = [1, 23, ‘hello’, 1].
a) list
b) dictionary
c) array
d) tuple
30. In order to store values in terms of key and value we use what core datatype.
a) list
b) tuple
c) class
d) dictionary
31. Which of the following results in a SyntaxError ?
a) ‘”Once upon a time…”, she said.’
b) “He said, ‘Yes!'”
c) ‘3\’
d) ”’That’s okay”’
32. The following is displayed by a print function call:
1.tom
2.dick
3.harry
a) -5
b) -4
c) -3
d) +3
40. What does ~~~~~~5 evaluate to?
a) +5
b) -11
c) +11
d) -5
41. Which of the following is incorrect?
a) x = 0b101
b) x = 0x4f5
c) x = 19023
d) x = 03964
42. What is the result of cmp(3, 1)?
a) 1
b) 0
c) True
d) False
43. Which of the following is incorrect?
a) float(‘inf’)
b) float(‘nan’)
c) float(’56’+’78’)
d) float(’12+34′)
44. What is the result of round(0.5) – round(-0.5)?
a) 1.0
b) 2.0
c) 0.0
d) None of the mentioned
45. What does 3 ^ 4 evaluate to?
a) 81 b) 12 c) 0.75 d) 7
46. The value of the expressions 4/(3*(2-1)) and 4/3*(2-1) is the same. State whether true or false.
a) True b) False
47. The value of the expression:
4+3%5
a) 4 b) 7 c) 2 d) 0
48. Evaluate the expression given below if A= 16 and B = 15.
A % B // A
a) 0.0 b) 0 c) 1.0 d) 1
49. Which of the following operators has its associativity from right to left?
a) + b) // c) % d) **
50. What is the value of x if: x = int(43.55+2/2)
a) 43 b) 44 c) 22 d) 23