LearnPythonDjango.com
Home
Tutorials
Courses
Quiz
Blog
Demo
About
Contact Us
Login
Register
Quiz Home
Python Quiz
1: Python is a High-level general purpose interpreted Langauge
True
False
2: What is a list comprehension in Python?
A way to create a list
A way to delete a list
A way to sort a list
3: What is the syntax to define a function in Python?
def function_name():
def function_name(args):
function function_name():
define function_name():
4: What is the output of the following code: print(len("Python"))?
6
7
5
5: Which keyword is used for creating a class in Python?
class
def
create
6: What is the result of 2 + 3 * 4?
14
20
11
7: How do you comment out a single line in Python?
#
//
/*
8: Which data type is used to store a sequence of characters in Python?
int
float
str
9: What is the purpose of the `if` statement in Python?
To create a loop
To define a function
To perform conditional execution
10: How do you open a file in Python for reading?
open("file.txt", "w")
open("file.txt", "r")
read("file.txt")
11: What is the result of `5 // 2` in Python?
2.5
2.0
2
12: Which library in Python is used for working with regular expressions?
regex
re
regexlib
13: What does the `len()` function in Python return for a string?
Number of lines in the string
Number of words in the string
Number of characters in the string
14: How do you import a module in Python?
use module_name
include module_name
import module_name
15: What is the purpose of the `elif` statement in Python?
To end a loop
To define a function
To specify an alternative condition
16: What is the result of `True and False` in Python?
True
False
Error
17: Which data type is used to store a collection of items in Python?
str
list
int
18: What is the symbol used for the exponentiation operator in Python?
**
//
^
19: What is the purpose of the `break` statement in Python?
To continue to the next iteration of a loop
To exit a loop prematurely
To create a loop
20: What is the result of `not True` in Python?
Error
True
False
21: Which built-in function can be used to obtain the length of a list or other iterable in Python?
size()
length()
len()
22: What is the purpose of the `try` and `except` blocks in Python?
To create a loop
To handle exceptions and errors
To define a function
23: Which method is used to add an item to the end of a list in Python?
append()
add()
insert()
24: What is the result of `'Hello' + ' ' + 'World'` in Python?
'Hello World'
'Hello+World'
'HelloWorld'
25: What does the `pop()` method do in Python when used with a list?
Deletes the last item
Adds an item