Python Quiz
Python Knowledge Quiz
Test your Python knowledge by answering the following questions:
Time Remaining: 05:00
1. Which of the following is the correct syntax to output "Hello World" in Python?
A) print("Hello World") B) echo("Hello World") C) printf("Hello World") D) printText("Hello World")2. What is the correct way to create a function in Python?
A) def myFunction(): B) function myFunction(): C) create myFunction(): D) function:myFunction()3. How do you insert COMMENTS in Python code?
A) # This is a comment B) // This is a comment C) /* This is a comment */ D)4. Which one is NOT a legal variable name in Python?
A) my-var B) my_var C) _myvar D) myvar5. How do you create a variable with the floating number 2.8?
A) x = 2.8 B) x = int(2.8) C) x = float(2.8) D) x = str(2.8)6. What is the correct file extension for Python files?
A) .py B) .python C) .pt D) .pyt7. Which method can be used to return a string in upper case letters?
A) upper() B) uppercase() C) toUpperCase() D) upperCase()8. Which of these collections defines a LIST?
A) ["apple", "banana", "cherry"] B) ("apple", "banana", "cherry") C) {"apple", "banana", "cherry"} D) {"name": "apple", "color": "red"}9. How do you start writing an if statement in Python?
A) if x > y then: B) if x > y: C) if (x > y) D) if x > y {10. Which keyword is used to create a class in Python?
A) class B) def C) create D) function