Python Quiz 2

PYTHON QUIZ 2

CONGRATULATIONS! YOU HAVE COMPLETED PYTHON QUIZ 2. YOU HAVE %%SCORE%% TRUE ANSWERS OUT OF %%TOTAL%% QUESTIONS. YOUR SCORE IS %%PERCENTAGE%%. %%RATING%%
Your answers are highlighted below.
Question 1
With which python method we remove the spaces at the beginning and end of a string?
A
remove()
B
sort()
C
strip()
D
replace()
E
del()
Question 2
If the result of the below python code is ['aaa', 'bbb', 'ccc', 'ddd'], what is the medhod used in --?-- part?
txt = "aaa#bbb#ccc#ddd"
x = txt.--?--("#")
print(x)
A
index
B
remove
C
join
D
split
E
upper
Question 3
Which python method combine two lists?
A
copy()
B
extend()
C
append()
D
sort()
E
insert()
Question 4
Which one do not allow duplicate members?
A
dictionary
B
set
C
tuple
D
list
E
all of them
Question 5
What is the Output of This Python Code?
list = [ "a", "b", "c", "d"]
x=len(list)
num = [1,2,3,4,5,3,4]
y=num.count(3)
z=x*y
print(z)
A
12
B
20
C
4
D
16
E
8
Question 6
What si the result of the below python code?
def multipfunc(*a):
    result=1
    for i in a:
               result=result * i
    print(result)
multipfunc(3,6,10)
A
10
B
1800
C
180
D
0
E
18
Question 7
Which one is Not a statement used with if else codes?
A
none of them
B
else
C
if
D
elseif
E
elif
Question 8
What is the result of this python code?
msg = "I like cats."
x = msg.find("cats")
print(x)
A
5
B
8
C
9
D
7
E
6
Question 9
What one is the correct file extension used by Python files?
A
.pyt
B
.p
C
.ptx
D
.py
E
.txt
Question 10
What is the output of the below python code?
numbers1 = {1,2,3}
numbers2 = {2,3,7,10,15}
numbers3 = numbers1.intersection(numbers2)
print(numbers3)
A
{1,2,3,7,10,15}
B
{2,3,7,10,15}
C
{1,2,2,3,3,7,10,15}
D
{1,2,3}
E
{2, 3}
Question 11
What is the output of this python code?
a = [10,20,30,40,50]
print(list(map(lambda x:x*5, a)))
A
[5, 10, 15, 20, 25]
B
[50, 100, 150, 200, 250]
C
[110, 120, 130, 140, 150]
D
[55, 150, 155, 250, 255]
E
none of them
Question 12
What is the output of this python code?
i = 5
list1 = []
while i < 10:
  list1.append(i)
  if (i == 8):
    break
  i += 1
print(list1)
A
[5, 6, 7, 8]
B
[6, 7, 8, 9]
C
[5, 6, 7, 8, 9]
D
[6, 7, 8]
E
[5, 6, 7, 8, 9, 10]
Question 13
How to access "wolf" and "lion" items in list x? 
x= ["eagle","bear","wolf", "lion", "tiger"]
A
x[2:5]
B
x[2:3]
C
x[3:5]
D
x[2:4]
E
x[3:4]
Question 14
What is the output of the below python code?
list1 = []
for x in range(1,10,1):
  if x%2 != 0:
    list1.append(x)
print(list1)
A
[1, 2, 3, 4, 5, 6, 7, 8, 9]
B
[0, 1, 3, 5, 7, 9]
C
[1, 3, 5, 7, 9]
D
[2, 4, 6, 8]
E
[2, 4, 6, 8, 10]
Question 15
How to access the first item in the list x?
A
x[ ]
B
x[0]
C
x[-1]
D
x[1]
E
none of them
Question 16
... statement stops the loop before it has looped through all the itemsi
A
continue
B
break
C
except
D
try
E
pass
Question 17
We have two sets: s1 = {1, 2, 3} and s2 = {3, 4, 5} Which one does NOT give their union?
A
s1 | [3, 4, 5]
B
s1.union({3, 4, 5})
C
none of them
D
s1.union([3, 4, 5])
E
s1 | set([3, 4, 5])
Question 18
What is the output of the below python code?
import math
x = math.ceil(3.4)
y = math.floor(2.7)
print(x+y)
A
6
B
8
C
7
D
5
E
4
Question 19
How to access "Hagi" item in tuple y?
y= ("Ronaldo","Messi","Hagi")
A
y[3]
B
y[-2]
C
y[-1]
D
y[2]
E
y[1]
Question 20
What is the output of this python code?
try:
  x=5
  print(x)
except:
  print("An Error!")
A
An Error!
B
Exception
C
x
D
5
E
None of them
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