NEW
Font size
WorksheetsPython Programming Quiz
Total questions: 40
Worksheet time: 20mins
What is the output of print(type(10))?
<class 'float'>
<class 'int'>
<class 'str'>
<class 'bool'>
What is the correct extension of a Python file?
.py
.python
.pyt
.pt
What is the keyword used to define a function in Python?
func
def
define
function
What will be the output of print(2 ** 3)?
5
6
8
9
How do you take input from a user in Python?
get()
scan()
input()
read()
What is the output of print(10/3)?
3.0
3.33
3
Error
What is the result of print(10 // 3)?
3.33
3.0
3
Error
Which of the following is immutable?
list
tuple
set
dictionary
What is the correct way to declare a list?
list = {1, 2, 3}
list = (1, 2, 3)
list = [1, 2, 3]
list = <1, 2, 3>
What does append() do in a list?
Adds an element at a specific index
Adds an element at the end
Removes the last element
Sorts the list
Which of the following is a valid variable name in Python?
1name
_name
name@
class
How do you create an empty set in Python?
s = {}
s = []
s = ()
s = set()
What will be the output of print("Hello"[1])?
H
e
l
o
What does range(5) return?
[0, 1, 2, 3, 4]
(0, 1, 2, 3, 4)
{0, 1, 2, 3, 4}
None
What will bool([]) return?
True
False
None
Error
How do you check the length of a list l?
length(l)
l.size()
len(l)
count(l)
Which statement is used to stop a loop?
exit
break
stop
return
Which loop executes at least once?
for
while
do-while
None
What is the output of print(type(None))?
Error
How do you remove an item from a list by value?
pop()
del
remove()
discard()
How do you create a dictionary?
{}
[]
()
<>
What is the default return type of input()?
int
float
str
bool
What is the keyword to define a class?
define
class
object
new
What is used to handle exceptions?
try-except
catch-throw
if-else
error handling
How do you access a value in a dictionary?
dict.key()
dict[key]
dict.key
dict.getvalue(key)
What will be the output of the following Python code? x = 5 y = 2 print(x ** y)
10
25
7
32
What will be the output of this code? def fun(): return 10 print(fun())
10
None
Error
0
What is the output of the following code? x = [1, 2, 3] y = x y.append(4) print(x)
[1, 2, 3]
[1, 2, 3, 4]
Error
[4]
What will be the output of this code? for i in range(3): print(i, end=" ")
0 1 2
1 2 3
0 1 2 3
None
What does the following code output? def add(a, b=5): return a + b print(add(2))
5
7
2
None
What is the output of this code? x = "Hello" print(x[::-1])
Hello
olleH
Error
None
What will be the output of the following code? x = [1, 2, 3] print(len(x))
2
3
1
Error
What is the output of this Python program? def multiply(x, y): return x * y print(multiply(3, 4))
12
7
3 * 4
None
What will be the output of this program? x = "Python" print(x[2:])
Py
thon
Python
Error
What is the output of the following Python script? for i in range(1, 4): for j in range(1, 4): print(i * j, end=" ") print()
1 2 3 2 4 6 3 6 9
1 2 3 4 5 6 7 8 9
1 4 9 1 4 9 1 4 9
None
What will be the output of print(bool([]))?
True
False
Error
None
What does list.append(4) do?
Adds 4 at the beginning
Adds 4 at the end
Removes 4
Does nothing
What is the output of print(type({}))?
What will print(5 % 2) return?
0
1
2
5
What does ord('A') return?
A
65
Error
None
