Python Quiz 3

PYTHON QUIZ 3

CONGRATULATIONS! YOU HAVE COMPLETED PYTHON QUIZ 3. YOU HAVE %%SCORE%% TRUE ANSWERS OUT OF %%TOTAL%% QUESTIONS. YOUR SCORE IS %%PERCENTAGE%%. %%RATING%%
Your answers are highlighted below.
Question 1
... block lets you test a block of code for errors.
A
try
B
raise
C
except
D
none of them
E
finally
Question 2
What is the output of this code? (Be careful :)
l1 = [1, [2, 3], 4]
l2 = l1.copy()
l2[1][1]=7
print(l1, l2)
A
[1, [2, 3], 4] [1, [2, 3], 4]
B
[1, [2, 7], 4] [1, [2, 7], 4]
C
[1, [2, 7], 4] [1, [2, 3], 4]
D
[1, [2, 3], 4] [1, [2, 7], 4]
E
none of them
Question 3
What is the result of this code?
import math
print(round(12.5)-round(10.7))
A
4
B
1
C
3
D
0
E
2
Question 4
What is the output of this python code?
i = 0
list1 = []
while i < 30:
if i%5==0:
list1.append(i)
i += 1
print(list1)
A
[5, 10, 15, 20, 25, 30]
B
[0, 5, 10, 15, 20, 25]
C
[0, 5, 10, 15, 20, 25, 30]
D
[5, 10, 15, 20, 25]
E
[5, 10, 15, 20]
Question 5
What is the result of this python code?
def findfactorial(a):
if a == 1:
return 1
else:
return (a * findfactorial(a-1))
print(findfactorial(5))
A
40
B
120
C
100
D
60
E
180
Question 6
What is the result of this python code?
list = [4,6,7,2,8]
list.insert(3,10)
print(list)
A
[4, 6, 7, 10, 2, 8]
B
[4, 6, 7, 2, 8, 10]
C
[4, 6, 7, 2, 8]
D
[4, 6, 7, 2, 8, 3]
E
[4, 6, 7, 3, 2, 8]
Question 7
Which symbol is used for comments in python?
A
-
B
//
C
/
D
*
E
#
Question 8
If statement, without indentation rises error.
A
False
B
True
Question 9
What is the output of this code?
try:
a=5
print(a)
except:
print("An Error!")
else:
print("All is Good!")
A
All is Good!
B
Exception
C
5
D
An Error!
E
5 All is Good!
Question 10
What is the Output of This Python Code?
a = 5
b = 2
c = 3
print((b**a-a*c)%b)
A
3
B
4
C
1
D
0
E
2
Question 11
How to create a function named FirstFunction?
A
create FirstFunction()
B
set FirstFunction():
C
create FirstFunction():
D
def FirstFunction():
E
def FirstFunction()
Question 12
What is the output of this code?
msg = "Welcome to python course!"
x = msg.index("python")
print(x)
A
10
B
9
C
8
D
11
E
12
Question 13
What is the maximum value for an integer in Python 3?
A
32767
B
65536
C
no limit
D
16512
E
0
Question 14
How to access the last item in the list x?
A
x[-]
B
x[1]
C
x[ ]
D
x[-%]
E
x[-1]
Question 15
How to access "wolf", "lion" and "tiger" items in list x? 
x= ["eagle","bear","wolf", "lion", "tiger"]
A
x[:2]
B
x[2:3]
C
x[-1:2]
D
x[2:]
E
x[3:]
Question 16
With which python method, we replace some part of a string?
A
change()
B
sort()
C
strip()
D
convert()
E
replace()
Question 17
What is the output of this python code?
numbers1 = {17,22,80}
numbers2 = {12,17,56,80,92}
print(numbers1.symmetric_difference(numbers2))
A
{12,17,22,56,80,92}
B
{17,22,80}
C
{12,17,17,22,56,80,80,92}
D
{12,17,56,80,92}
E
{22, 56, 12, 92}
Question 18
What is the output of this python code?
numbers1 = {1,2,3}
numbers2 = {2,3,7,10,15}
print(numbers2.difference(numbers1))
A
{1,2,3,7,10,15}
B
{1,2,3}
C
{10, 15, 7}
D
none of them
E
{2,3,7,10,15}
Question 19
What is the output of the below python code?
list=[]
for x in range(1,10,1):
list.append(pow(x,2))
print(list)
A
[1, 10]
B
[1, 2, 3, 4, 5, 6, 7, 8, 9]
C
[1, 100]
D
[1, 3, 5, 7, 9]
E
[1, 4, 9, 16, 25, 36, 49, 64, 81]
Question 20
What is the Output Of This Python Math Code?
import math
print(math.sqrt((pow(5,2)-5)*5))
A
20.0
B
15.0
C
30.0
D
10.0
E
25.0
Once you are finished, click the button below. Any items you have not completed will be marked incorrect. Get Results
There are 20 questions to complete.
gokhan-kosem-instructor-ipcisco

Gokhan Kosem is a Network Engineer, Instructor and the Founder of IPCisco.com with 15+ years of experience in Cisco, Nokia, Huawei, Juniper, Linux, Service Provider Networks, Routing and Switching technologies.

He has worked on the backbone networks of major service providers and network vendors including Nortel, Alcatel-Lucent (Nokia) and has extensive hands-on experience with Cisco, Huawei, Juniper and Nokia networking technologies.

He has trained thousands of networking students worldwide through IPCisco.com, Udemy, books, labs, quizzes, and educational content across multiple social media platforms.

IPCisco.com | Best Route to Your Dreams