You are on page 1of 3

Multiple Choice Questions

1. Python Was developed by _____________ in (a) stub (b) function


_____________? (c) re (d) map
(a) James Goshling, 1995 11. _____________ in python are essentially functions
(b) Guido Van Rossum, 1991 that add functionality to a real function in Python
(c) Dennis M. Ritchie, 1975 without changing the structure of the function itself.
(d) Bjarne Stroustrup, 1998 (a) Construtors (b) Decorators
2. Why Python is Dynamically-Typed Language (c) Generators (d) None of these
_____________? 12. Serialization process in python done by
(a) Because of Type-coercion _____________.
(b) Because of Type-Checking (a) Unpicking (b) generators
(c) Both a and b (c) pickling (d) None of these
(d) None of the above 13. _____________ is an object in python and it
3. Which one of the Following is an extension of remembers it’s state.
Python? (a) Deorators (b) Generators
(a) .py (b) .html (c) Iterables (d) Iterators
(c) .p (d) .python 14. We can generate random number by using
4. Python support _____________ Language. _____________ method in python?
(a) Object-Oriented Programming (a) lambda (b) random
(b) Structural Programming (c) range (d) rand
(c) Functional Programming 15. What does ~~~~~7 in python?
(d) All of these (a) –7 (b) 70
5. Which of the following is a not a core data type in (c) 7 (d) –12
python? 16. x = 'efg' _____________ for i in x: _____________
(a) set (b) class print(i.upper())?
(c) string (d) dictionary (a) 1234 (b) 4321
6. Which one of the following is not a keyword in (c) error (d) none of these
Python? 17. print (1+4*3)?
(a) pass (b) eval (a) 13 (b) 15
(c) assert (d) non-local (c) 12 (d) 11
7. Length of a python identifier _____________. 18. K = set(‘abc@de’) _____________ ‘e’ in k?
(a) 24 (b) 128 (a) TRUE (b) FALSE
(c) 32 (d) not fixed 19. x = ['ab', 'cd'] _____________ for i in x:
8. Python supports the creation of anonymous functions _____________ x.append(i.upper()) _____________
at runtime, using a construct called? print(x)?
(a) pi (b) def (a) [‘AB’, ‘CD’]
(c) lambda (d) none of these (b) [‘ab’, ‘cd’, ‘AB’, ‘CD’]
9. Given a String s = “Hello world” which of the (c) [‘ab’, ‘cd’]
following code is correct? (d) none of these
(a) s[1] = l (b) s[4] = o 20. Which of the following rounding strategies mitigates
(c) s[6] = r (d) s[9] = d rounding bias the best?
10. _____________ is a simple but incomplete version (a) Round half to even (b) Round down
of a function. (c) Round half up (d) Truncate
2 Python Programming

21. Which rounding strategy does Python’s built-in 32. PEP stands for?
round() function use? (a) Python Enhancement Proposal
(a) Round down (b) Python Exposure Proposal
(b) Round half to even (c) Python Exposed Proposal
(c) trauncate (d) Round half up (d) None
22. When a value is truncated to 3 decimal places, which 33. a = [1, 8] _____________ print(a * 3)?
of the following is true? (a) Error
(a) Positive numbers are rounded up and negative (b) [1,8]
numbers are rounded down. (c) [1,8,1,8,1,8,1,8,1,8,1,8,1,8]
(b) Positive numbers are rounded down and nega- (d) [1,8,1,8,1,8]
tive numbers are rounded up. 34. Can python support parameter-passing mechanism?
23. The minsplit parameter to split() specifies the (a) Yes (b) No
minimum number of splits to make to the input 35. The _____________ is a way to declare a list in one
string. line of code.
(a) TRUE (b) FALSE (a) lambda (b) list manipulation
24. In Python which built-in function returns the unique (c) list comprehension (d) zip
number assigned to an object? 36. When a function makes a call to itself, it is termed as
(a) refnum() (b) ref() _____________.
(c) id() (d) none of these (a) anonymous (b) recursion
25. In Python, a variable must be declared before it is (c) repetition (d) none
assigned a value. 37. _____________ is a technique that allows us to
(a) TRUE (b) FALSE retrieve only a part of a list, tuple, or string.
26. You are a Python developer at Turing. You want to (a) Slicing (b) Operator
get the current position of the file. How can you do (c) Indexing (d) Decorator
it? 38. The function pow(x,y,z) is evaluated as:
(a) fp.seek() (b) fp.loc() (a) (x**y)**z (b) (x**y)/z
(c) fp.tell() (d) fp.pos() (c) (x**y) % z (d) (x**y)*z
27. Which of the following statements about xrange in 39. a={4,5,6} , b={2,8,6} _____________ a–b?
python are FALSE? (a) {4,5} (b) {6}
(a) xange provides a way to generate a list of (c) Both a and b (d) None
integers 40. Which of the following Bitwise operators sets each
(b) The xrange generates a static list at run-time bit to 1, if only one of them is 1, i.e. if only one of the
(c) xrange returns a Python list object two operands are 1.
(d) if you want to create a big list object, xrange is (a) OR (b) AND
the better choice to use (c) NOT (d) XOR
28. print(2**(3**2), (2**3)**2, (2**3)**3)? 41. How to compare two objects and check whether they
(a) 64, 512, 64 (b) 64, 64, 64 have the same memory locations?
(c) 512, 512, 512 (d) 512, 64, 512 (a) is operator (b) in operator
29. The {} side {1} {2}'.format('bright', 'of', 'life') (c) ** (d) <==>
(a) Error 42. How to display only the day number of year in
(b) The bright side of life Python?
(c) no output (a) date.strftime(“%p”)
(d) The {bright} side {of} {life}' (b) date.strftime(“%j”)
30. Which of the following is incorrect about mode to (c) date.strftime(“%H”)
open the file? (d) date.strftime(“%I”)
(a) a+ (b) r+ 43. How to swap cases in Python i.e. lowercase to
(c) rw (d) w+ uppercase and vice versa?
31. Which of the following statements is INCORRECT (a) casefold() method (b) title() method
about a valid attribute of a file object in Python? (c) swapcase() method (d) case() method
(a) file.size (b) file.mode 44. Which of the following is the correct way to indicate
(c) file.name (d) file.closed Hexadecimal Notation in Python?
Multiple Choice Questions 3

(a) str = ‘\62’ (b) str = ’62’ 49. a = 89 == 3, print(a)?


(c) str = “62” (d) str = ‘\x62’ (a) TRUE (b) FALSE
45. How to we define a constructor of a class named (c) Wrong syntax (d) 89 == 3
"Person" in Python? 50. What happened if 2 == '2' executed?
(a) def Person(): (b) def __init__(self): (a) TRUE (b) FALSE
(c) def __init__(): (d) def Person: (c) 2 (d) None of these
46. What is the meaning of Abstraction in the light of 51. What will be the output of this program? print(True
Object Oriented Programming? ** False/True)
(a) Keeping code and data separate. (a) True ** False/True (b) 2
(b) Defining a class which doesn't do any work. (c) 1 (d) None of these
(c) Hiding implementation details from the user. 52. Is Python case sensitive when dealing with
(d) Wrapping up of code and data in the same identifiers?
container. (a) Yes (b) No
47. Why is Encapsulation necessary in Python? (c) Machine Dependent (d) None of these
(a) To protect members of a class from unauthor- 53. Denmark is a birth place of which programming
ized access. language?
(b) To reduce size of the codebase. (a) Python (b) C++
(c) To separate attributes of different objects. (c) Java (d) None of these
(d) None of the above. 54. Using loop inside another loop is called as
48. a = [[], "abc", [0], 1, 0] _____________ _____________.
print(list(filter(bool, a)))? (a) two loop (b) inside loop
(a) ['abc',[0],1 (b) [1] (c) inner loop (d) nested loop
(c) [abc] (d) [1,0]

Answers
1. (b)  2. (c)  3. (a)  4. (d)  5. (b)  6. (b)  7. (d)  8. (c)  9. (b) 10. (a) 11. (b) 12. (c)
13. (d) 14. (b) 15. (c) 16. (b) 17. (a) 18. (a) 19. (d) 20. (a) 21. (b) 22. (b) 23. (b) 24. (c)
25. (b) 26. (b) 27. (d) 28. (d) 29. (c) 30. (a) 31. (d) 32. (a) 33. (d) 34. (a) 35. (c) 36. (b)
37. (a) 38. (c) 39. (a) 40. (d) 41. (a) 42. (b) 43. (c) 44. (d) 45. (b) 46. (c) 47. (a) 48. (a)
49. (b) 50. (b) 51. (c) 52. (a) 53. (b) 54. (d)

You might also like