Python 3 MCQ (SET-6) – Multiple Choice Questions and Answers

  1. What will be the output after the following statements?
    x = ‘2.7’
    print(x.isdecimal())
    a. True
    b. False
    c. 1
    d. 0
  2. What does the following statement do?
    x = open(‘python.csv’, ‘r’)
    a. Opens an existing text file named python.csv to write
    b. Opens an existing text file named python.csv to append
    c. Opens an existing text file named python.csv to read
    d. Opens a new file named python.csv to read
  3. What does the following statement do?
    x = open(‘python.csv’, ‘w’)
    a. Opens or creates a text file named python.csv to write
    b. Opens or creates a text file named python.csv to append
    c. Opens or creates a text file named python.csv to read
    d. Opens a new file named python.csv to write
  4. What does the following statement do?
    x = open(‘python.csv’, ‘a’)
    a. Opens or creates a text file named python.csv to write
    b. Opens or creates a text file named python.csv to append
    c. Opens or creates a text file named python.csv to read
    d. Opens a new file named python.csv to append
  5. What does the following statement do?
    x = open(‘python.txt’, ‘r+’)
    a. Opens a text file named python.txt to read from or write to
    b. Opens a text file named python.txt to read
    c. Opens a text file named python.txt to write
    d. Opens a new file named python.txt to append
  6. What does the following statement do?
    x = open(‘python.txt’, ‘w+’)
    a. Opens a text file named python.txt to read
    b. Opens a text file named python.txt to write to or read from
    c. Opens a text file named python.txt to write
    d. Opens a new file named python.txt to append
  7. What does the following statement do?
    x = open(‘python.txt’, ‘a+’)
    a. Opens a text file named python.txt to read
    b. Opens a text file named python.txt to read and write
    c. Opens a text file named python.txt to write to
    d. Opens or creates a text file named python.txt to read from or write to at the end of the file
  8. What does the following statement do?
    x = open(‘python.bat’, ‘rb’)
    a. Opens an existing text file named python.bat to write
    b. Opens an existing binary file named python.bat to write
    c. Opens an existing binary file named python.bat to append
    d. Opens an existing binary file named python.bat to read
  9. What does the following statement do?
    x = open(‘python.bat’, ‘wb’)
    a. Opens or creates a binary file named python.bat to write
    b. Opens or creates a binary file named python.bat to append
    c. Opens or creates a binary file named python.bat to read
    d. Opens a new file named python.bat to write
  10. What does the following statement do?
    x = open(‘python.bat’, ‘ab’)
    a. Opens or creates a binary file named python.bat to write
    b. Opens or creates a binary file named python.bat to append
    c. Opens or creates a binary file named python.bat to read
    d. Opens a new file named python.bat to append
  11. What will be the output after the following statements?
    x = open(‘python.txt’, ‘r’)
    print(x.name)
    a. python
    b. python.txt opened
    c. python.txt or FileNotFoundError
    d. python r
  12. What will be the output after the following statements?
    x = open(‘python.csv’, ‘w’)
    print(x.mode)
    a. python write
    b. python.txt
    c. r
    d. w
  13. What will be the output after the following statements?
    x = open(‘python.csv’, ‘w’)
    print(x.closed)
    a. open
    b. closed
    c. True
    d. False
  14. What will be the output after the following statements?
    x = open(‘python.csv’, ‘w’)
    x.close()
    print(x.closed)
    a. open
    b. closed
    c. True
    d. False
  15. What will be the output after the following statements?
    x = open(‘python.csv’, ‘w’)
    print(x.readable())
    a. readable
    b. writable
    c. True
    d. False
  16. What will be the output after the following statements?
    x = open(‘python.csv’, ‘w’)
    print(x.writable())
    a. readable
    b. writable
    c. True
    d. False
  17. What will be the output after the following statements?
    x = open(‘python.csv’, ‘a’)
    print(x.writable())
    a. readable
    b. writable
    c. True
    d. False
  18. In IDLE shell, the output will be the same for all the following statements
    except one. Which one?
    a. 4+4
    b. 4 + 4
    c. 4*2
    d. 4**2
  19. In IDLE shell, what is the keyboard shortcut for the previous command in
    history on Windows/Linux?
    a. Page Down
    a. Page Down
    b. Page Up
    c. Alt + P
    d. Ctrl + P
  20. In IDLE shell, what is the keyboard shortcut for the next command in
    history on Windows/Linux?
    a. Page Down
    b. Page Up
    c. Ctrl + N
    d. Alt + N
  21. In IDLE shell, what is the keyboard shortcut for the previous command in
    history on Mac OS X?
    a. Page Down
    b. Page Up
    c. Alt + P
    d. Ctrl + P
  22. In IDLE shell, what is the keyboard shortcut for the next command in
    history on Mac OS X?
    a. Page Down
    b. Page Up
    c. Ctrl + N
    d. Alt + N
  23. In IDLE file editor, what is the keyboard shortcut for executing the program
    in shell?
    a. F5
    b. F1
    c. Shift
    d. Alt
  24. What type of error is shown when you use a variable without assigning an
    initial value?
    a. Not declared
    b. Not defined
    c. Not assigned
    d. Not a variable
  25. What type of language is Python?
    a. High level
    b. Low level
    c. Top level
    d. Bottom level
  26. Python language was named after?
    a. Python – the reptile
    b. Monty Python
    c. A pet
    d. A company
  27. Who is the creator of Python?
    a. Bill Gates
    b. Guido Van Rossum
    c. Jeff Bezos
    d. Larry Page
  28. Which of the following is identified with Python?
    a. Dynamic typing
    b. Static typing
    c. Slow typing
    d. Auto typing
    d. Auto typing
  29. Which of the following is used to enclose strings?
    a. Single quotes
    b. Double quotes
    c. Either single quotes or double quotes
    d. ! symbol
  30. Which of the following is used to add an invisible tab character to the
    output?
    a. \t
    b. \tab
    c. \a
    d. \b
  31. What will be the output after the following statement?
    print(‘2\\t4’)
    a. 2 t 4
    b. 2\t4
    c. 2 4
    d. 2 tab 4
  32. What will be the output after the following statements?
    a = True
    b = False
    c = 5 if (a == 1) else b
    print(c)
    a. True
    b. False
    c. b
    d. 5
  33. What will be the output after the following statements?
    a = True
    b = False
    c = ‘a’ if (b == 0) else ‘b’
    print(c)
    a. True
    b. False
    c. a
    d. b
  34. What will be the output after the following statements?
    a = False
    b = False
    print(a and b)
    a. True
    b. False
    c. ab
    d. ba
  35. In the order of precedence, which of the operation will be completed first in
    the following statement?
    3 * 6 + 5 – 4 / 2
    a. Multiplication
    b. Division
    c. Addition
    d. Subtraction
  36. In the order of precedence, which of the operation will be completed last in
    the following statement?
    3 * 6 + 5 – 4 / 2
    a. Multiplication
    b. Division
    c. Addition
    d. Subtraction
  37. What will be the order of precedence of operations in the following
    statement?
    10 * 4 – 1 + 8 / 5
    a. Multiplication, Division, Subtraction, Addition
    b. Multiplication, Division, Addition, Subtraction
    c. Division, Multiplication, Subtraction, Addition
    d. Division, Multiplication, Addition, Subtraction
  38. What will be the data type of x after the following statement if input entered
    is 64?
    x = float(input(‘Enter a number: ‘))
    a. Integer
    b. String
    c. List
    d. Float
  39. What will be the output after the following statements?
    a = 27 / 3 % 2 * 4**2
    print(a)
    a. 0
    b. 16.0
    c. 32
    d. 4.0
  40. What will be the output after the following statements?
    a = 3 / 3 47 – 3*3
    print(a)
    a. 20.0
    b. 1.0
    c. 36.0
    d. 0.0
  41. What will be the output after the following statements?
    a = [1,3,5,7,9,11,13,15,17,19]
    print(a[1:5],a[3:17])
    a. [3, 5, 7, 9]
    b. [1, 3, 5] [3, 5, 7, 9, 11, 13, 15, 17]
    c. [3, 5, 7, 9] [7, 9, 11, 13, 15, 17, 19]
    d. [3, 5, 7, 9, 11, 13, 15, 17, 19]
  42. What will be the output after the following statements?
    a = [1,3,5]
    print(a * 2)
    a. [1, 3, 5, 1, 3, 5]
    b. [1, 2, 3, 5]
    c. [3, 5]
    d. [11, 33, 55]
  43. Which of the following is not a valid variable name?
    a. abc
    b. abc123
    c. 123abc
    d. abc_123
  44. Which of the following is a valid variable name?
    a. a$1
    b. a1
    c. 1a
    d. abc 123
  45. What will be the output after the following statements?
    a = 15
    b = a
    a = 25
    print(a,b)
    a. 25 15
    b. 15 25
    c. a 15
    d. 25 a
  46. What will be the output after the following statements?
    x = 16 / 4 * 5
    y = 16 / 4 * 5.0
    z = 16 / 4.0 * 5
    print(x, y, z)
    a. 25 15 20
    b. 20.0 20.0 20.0
    c. 20.0 20 20.0
    d. 20 20.0 20
  47. What will be the data type of x after the following statement?
    x = 1/2
    a. Integer
    b. List
    c. String
    d. Float
  48. What will be the output after the following statements?
    def x(y,z):
    pass
    x(1,4)
    a. 1,4
    b. y,z
    c. No output
    d. None
  49. What will be the output after the following statements?
    b = 1
    for a in range(1, 10, 3):
    b += a + 1
    print(b)
    a. 14
    b. 16
    c. 20
    d. 25
  50. What will be the output after the following statements?
    b = 1
    for a in range(1, 10):
    b += a – 1
    print(b)
    a. 37
    b. 47
    c. 44
    d. 38
SHARE:

Leave a Comment