Python Basics MCQ

Test your fundamentals of Python programming with this beginner-friendly quiz covering variables, data types, loops, and functions.

10 Questions beginner

Quiz Questions

  1. What is the correct way to declare a variable in Python?
    • var x = 5
    • int x = 5
    • x = 5
    • declare x = 5
  2. Which of the following is a valid Python data type?
    • integer
    • string
    • list
    • All of the above
  3. What will print(type(3.14)) output?
    • <class 'int'>
    • <class 'float'>
    • <class 'double'>
    • <class 'decimal'>
  4. How do you create a comment in Python?
    • // comment
    • /* comment */
    • # comment
    • <!-- comment -->
  5. What is the output of len('Hello')?
    • 4
    • 5
    • 6
    • Error
  6. Which keyword is used to define a function in Python?
    • function
    • def
    • func
    • define
  7. What will be the output of 2 ** 3?
    • 5
    • 6
    • 8
    • 9
  8. Which of the following is used to get user input in Python 3?
    • scanf()
    • input()
    • read()
    • get()
  9. What does the range(5) function return?
    • [1, 2, 3, 4, 5]
    • [0, 1, 2, 3, 4]
    • [0, 1, 2, 3, 4, 5]
    • A range object from 0 to 4
  10. How do you check if a key exists in a dictionary?
    • key.exists(dict)
    • dict.has(key)
    • key in dict
    • dict.contains(key)
Take this Quiz