Python Beginner Quiz

1. How do you declare a variable in Python?

a) int x = 5;
b) x = 5
c) var x = 5;
d) declare x = 5;

2. What is the output of `print(10 / 3)`?

a) 3
b) 3.3333333333333335
c) 4
d) Error

3. True or False: Python is case-sensitive.

a) True
b) False

4. What is the correct syntax for a for loop in Python?

a) for (int i = 0; i < 5; i++)
b) for i in range(5):
c) loop(i, 0, 5)
d) for i = 0 to 5

5. What does `input()` do?

a) Prints a string
b) Reads user input
c) Declares a variable
d) Exits the program

6. What does `len("hello")` return?

a) 4
b) 5
c) 6
d) Error

7. How do you write a comment in Python?

a) // Comment
b) # Comment
c) /* Comment */
d)

8. True or False: Python requires variable type declarations.

a) True
b) False

9. What is the output of `print(2 * "hi")`?

a) hi
b) hihi
c) 4
d) Error

10. What is the scope of a variable defined in a function?

a) Global
b) Local to the function
c) File-wide
d) Permanent