PYTHON Basics and Syntax MCQs

  1. Which of the following is true about Python variables?
    a) They must be declared with a type
    b) They can change type dynamically
    c) They cannot store strings
    d) They are always global
    View Answer

    Correct answer: B — They can change type dynamically

  2. What will be printed?
    1 print("Eduinq"[0:3])
    a) Edu
    b) Edi
    c) duq
    d) Error
    View Answer

    Correct answer: A — Edu

  3. Which operator is used for floor division in Python?
    a) /
    b) //
    c) %
    d) **
    View Answer

    Correct answer: B — //

  4. What is the default return value of a function that does not explicitly return anything?
    a) None
    b) 0
    c) Empty string
    d) Error
    View Answer

    Correct answer: A — None

  5. What will be printed?
    1 print("Eduinq" * 2)
    a) EduinqEduinq
    b) Eduinq 2
    c) Error
    d) EduinqEduinqEduinq
    View Answer

    Correct answer: A — EduinqEduinq

  6. Which of the following is immutable in Python?
    a) List
    b) Dictionary
    c) Tuple
    d) Set
    View Answer

    Correct answer: C — Tuple

  7. Which symbol is used for comments in Python?
    a) //
    b) #
    c) /* */
    d) --
    View Answer

    Correct answer: B — #

  8. What will be printed?
    1 print(type(True))
    a) <class 'int'>
    b) <class 'bool'>
    c) <class 'str'>
    d) <class 'float'>
    View Answer

    Correct answer: B — <class 'bool'>

  9. Which of the following is not a Python keyword?
    a) pass
    b) assert
    c) eval
    d) yield
    View Answer

    Correct answer: C — eval

  10. Which function is used to get user input in Python 3?
    a) scan()
    b) input()
    c) read()
    d) get()
    View Answer

    Correct answer: B — input()

  11. What is the output of print(2**32)?
    a) 64
    b) 512
    c) 256
    d) 8
    View Answer

    Correct answer: B — 512

  12. Which of the following is immutable in Python?
    a) List
    b) Dictionary
    c) Tuple
    d) Set
    View Answer

    Correct answer: C — Tuple

  13. What is the output of print(type(True))?
    a) <class 'int'>
    b) <class 'bool'>
    c) <class 'str'>
    d) <class 'float'>
    View Answer

    Correct answer: B — <class 'bool'>

  14. Which symbol is used for comments in Python?
    a) //
    b) #
    c) /* */
    d) --
    View Answer

    Correct answer: B — #

  15. What will print(10 == 10.0) output?
    a) True
    b) False
    c) Error
    d) None
    View Answer

    Correct answer: A — True

  16. Which of the following is used to define a block of code in Python?
    a) Braces {}
    b) Indentation
    c) Parentheses ()
    d) Colon : only
    View Answer

    Correct answer: B — Indentation

  17. What is the output of print("Eduinq"[::-1])?
    a) qniudE
    b) Eduinq
    c) Error
    d) qniduE
    View Answer

    Correct answer: A — qniudE

  18. Which function converts a string to an integer in Python?
    a) str()
    b) int()
    c) float()
    d) eval()
    View Answer

    Correct answer: B — int()

  19. What is the output of print(5//2)?
    a) 2.5
    b) 2
    c) 3
    d) Error
    View Answer

    Correct answer: B — 2

  20. Which of the following is not a valid data type in Python?
    a) List
    b) Array
    c) Tuple
    d) Set
    View Answer

    Correct answer: B — Array

  21. What is the output of print(type(None))?
    a) <class 'NoneType'>
    b) <class 'null'>
    c) <class 'object'>
    d) <class 'empty'>
    View Answer

    Correct answer: A — <class 'NoneType'>

  22. Which operator is used for exponentiation in Python?
    a) ^
    b) **
    c) ^^
    d) exp
    View Answer

    Correct answer: B — **

  23. What is the output of print(3*'Eduinq')?
    a) EduinqEduinqEduinq
    b) Eduinq3
    c) Error
    d) Eduinq Eduinq Eduinq
    View Answer

    Correct answer: A — EduinqEduinqEduinq

  24. Which of the following is used to check object identity?
    a) ==
    b) is
    c) in
    d) !=
    View Answer

    Correct answer: B — is

  25. What is the output of print(10%3)?
    a) 1
    b) 3
    c) 0
    d) Error
    View Answer

    Correct answer: A — 1

  26. Which of the following is not a valid Boolean value in Python?
    a) True
    b) False
    c) None
    d) Yes
    View Answer

    Correct answer: D — Yes

  27. What is the output of print(type(3.14))?
    a) <class 'int'>
    b) <class 'float'>
    c) <class 'double'>
    d) <class 'decimal'>
    View Answer

    Correct answer: B — <class 'float'>

  28. Which of the following is used to import a module in Python?
    a) include
    b) import
    c) using
    d) require
    View Answer

    Correct answer: B — import

  29. What is the output of print(len("Eduinq"))?
    a) 6
    b) 7
    c) 8
    d) Error
    View Answer

    Correct answer: B — 7

  30. Which of the following is not a valid escape character in Python?
    a)
    b)
    c)
    d) x
    View Answer

    Correct answer: D — x

  31. What is the output of print(2==2 and 3==4)?
    a) True
    b) False
    c) Error
    d) None
    View Answer

    Correct answer: B — False

  32. Which of the following is used to terminate a loop in Python?
    a) stop
    b) exit
    c) break
    d) end
    View Answer

    Correct answer: C — break

  33. What is the output of print(2!=3)?
    a) True
    b) False
    c) Error
    d) None
    View Answer

    Correct answer: A — True

  34. Which of the following is used to continue to the next iteration in a loop?
    a) skip
    b) continue
    c) next
    d) pass
    View Answer

    Correct answer: B — continue

  35. What is the output of print("Eduinq".upper())?
    a) eduinq
    b) EDUINQ
    c) Eduinq
    d) Error
    View Answer

    Correct answer: B — EDUINQ

  36. Which of the following is not a valid numeric type in Python?
    a) int
    b) float
    c) complex
    d) decimal
    View Answer

    Correct answer: D — decimal

  37. What is the output of print(5==5 or 2==3)?
    a) True
    b) False
    c) Error
    d) None
    View Answer

    Correct answer: A — True

  38. Which of the following is used to define a class in Python?
    a) class
    b) define
    c) object
    d) struct
    View Answer

    Correct answer: A — class

  39. What is the output of print("Eduinq".find("q"))?
    a) 5
    b) 6
    c) -1
    d) Error
    View Answer

    Correct answer: A — 5

  40. Which of the following is not a valid string method in Python?
    a) split()
    b) join()
    c) append()
    d) replace()
    View Answer

    Correct answer: C — append()

  41. What is the output of print(10//3)?
    a) 3
    b) 3.33
    c) 4
    d) Error
    View Answer

    Correct answer: A — 3

  42. Which of the following is used to check membership in Python?
    a) in
    b) is
    c) ==
    d) not
    View Answer

    Correct answer: A — in

  43. What is the output of print("Eduinq"[-1])?
    a) E
    b) q
    c) Error
    d) n
    View Answer

    Correct answer: B — q

  44. Which of the following is not a valid Python numeric literal?
    a) 0b101
    b) 0x1F
    c) 07
    d) 3.14
    View Answer

    Correct answer: C — 07

  45. What is the output of print("5" + "5")?
    a) 10
    b) 55
    c) Error
    d) None
    View Answer

    Correct answer: B — 55

  46. Which of the following is used to convert a list into a tuple?
    a) list()
    b) tuple()
    c) set()
    d) dict()
    View Answer

    Correct answer: B — tuple()

  47. What is the output of print(type(3/3))?
    a) <class 'int'>
    b) <class 'float'>
    c) <class 'decimal'>
    d) <class 'double'>
    View Answer

    Correct answer: B — <class 'float'>

  48. Which of the following is used to remove whitespace from both ends of a string?
    a) strip()
    b) trim()
    c) remove()
    d) clean()
    View Answer

    Correct answer: A — strip()

  49. What is the output of print(2*3+4)?
    a) 10
    b) 14
    c) 12
    d) 20
    View Answer

    Correct answer: A — 10

  50. Which of the following is used to display the documentation string of a function in Python?
    a) help()
    b) doc()
    c) info()
    d) manual()
    View Answer

    Correct answer: A — help()

Quick Links to Explore