Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

150 Best Beginner-Level Python MCQs

  1. Which of the following is used to create a thread in Python?
    a) threading.Thread
    b) multiprocessing.Process
    c) asyncio.Task
    d) concurrent.Future
    Correct Answer: a) threading.Thread
  2. What is the output of print("Python".isnumeric())?
    a) True
    b) False
    c) Error
    d) None
    Correct Answer: b) False
  3. Which of the following is used to create a file in Python?
    a) open()
    b) read()
    c) write()
    d) close()
    Correct Answer: a) open()
  4. What is the output of print("Python".isdecimal())?
    a) True
    b) False
    c) Error
    d) None
    Correct Answer: b) False
  5. Which of the following is used to create a set in Python?
    a) {}
    b) []
    c) ()
    d) <>
    Correct Answer: a) {}
  6. What is the output of print("Python".isspace())?
    a) True
    b) False
    c) Error
    d) None
    Correct Answer: b) False
  7. Which of the following is used to create a frozen set in Python?
    a) frozenset()
    b) set()
    c) frozen()
    d) freeze()
    Correct Answer: a) frozenset()
  8. What is the output of print("Python".isupper())?
    a) True
    b) False
    c) Error
    d) None
    Correct Answer: b) False
  9. Which of the following is used to create a range of numbers in Python?
    a) range()
    b) list()
    c) tuple()
    d) set()
    Correct Answer: a) range()
  10. What is the output of print("Python".swapcase())?
    a) pYTHON
    b) PYTHON
    c) python
    d) Error
    Correct Answer: a) pYTHON
  11. Which of the following is used to create a list comprehension in Python?
    a) [x for x in iterable]
    b) {x for x in iterable}
    c) (x for x in iterable)
    d) <x for x in iterable>
    Correct Answer: a) [x for x in iterable]
  12. What is the output of print("Python".zfill(10))?
    a) 0000Python
    b) Python0000
    c) Python
    d) Error
    Correct Answer: a) 0000Python
  13. Which of the following is used to create a dictionary comprehension in Python?
    a) {key: value for key, value in iterable}
    b) [key: value for key, value in iterable]
    c) (key: value for key, value in iterable)
    d) <key: value for key, value in iterable>
    Correct Answer: a) {key: value for key, value in iterable}
  14. What is the output of print("Python".ljust(10, "*"))?
    a) Python****
    b) Python
    c) Python
    d) Error
    Correct Answer: a) Python
  15. Which of the following is used to create a set comprehension in Python?
    a) {x for x in iterable}
    b) [x for x in iterable]
    c) (x for x in iterable)
    d) <x for x in iterable>
    Correct Answer: a) {x for x in iterable}

x
Advertisements
Advertisements