AllInfoHub Logo

AllInfoHub – MCQ Practice

Basics of Python – Multiple Choice Questions (MCQs)

  1. 49. What is the purpose of the `pass` statement in Python?

    • A. To exit a loop
    • B. To skip the current iteration
    • C. To define an empty block of code
    • D. To define a comment
  2. 50. What is the output of `print(list(range(1, 5)))`?

    • A. [1
    • B. 2
    • C. 3
    • D. 4
  3. 51. What is the output of `print('hello'.upper())`?

    • A. HELLO
    • B. Hello
    • C. hELLo
    • D. hellO
  4. 52. What is the output of `print('WORLD'.lower())`?

    • A. world
    • B. WORLD
    • C. WorLd
    • D. wORLD
  5. 53. What is string concatenation in Python?

    • A. Joining two or more strings together
    • B. Converting a string to uppercase
    • C. Converting a string to lowercase
    • D. Finding the length of a string
  6. 54. What is the output of `print('abc' * 3)`?

    • A. abcabc
    • B. abc 3
    • C. aaabbbccc
    • D. abcabcabc
  7. 55. What is string slicing in Python?

    • A. Modifying a string in place
    • B. Extracting a portion of a string
    • C. Finding the index of a substring
    • D. Reversing a string
  8. 56. What is the output of `print('example'[2:5])`?

    • A. amp
    • B. xampl
    • C. ample
    • D. mpl
  9. 57. What is the output of `print('example'[:3])`?

    • A. exa
    • B. ample
    • C. exam
    • D. ex
  10. 58. What is the output of `print('example'[3:])`?

    • A. ample
    • B. exam
    • C. xample
    • D. mple
  11. 59. What is the output of `print('example'[-1])`?

    • A. e
    • B. l
    • C. p
    • D. a
  12. 60. What is the output of `print('example'[-3:])`?

    • A. ple
    • B. mpl
    • C. ample
    • D. xple