Python Quiz 4

PYTHON QUIZ 4

CONGRATULATIONS! YOU HAVE COMPLETED PYTHON QUIZ 4. YOU HAVE %%SCORE%% TRUE ANSWERS OUT OF %%TOTAL%% QUESTIONS. YOUR SCORE IS %%PERCENTAGE%%. %%RATING%%
Your answers are highlighted below.
Question 1
What is the output of the below python code?
numbers = [4,6,8,9,4,6,7,3,4,5]
x = numbers.count(4)
print(x)
A
10
B
4
C
3
D
1
E
0
Question 2
Which commands combine the items of list?
A
x.join("")
B
"".join(x)
C
"-".join(x)
D
x.join("-")
E
x.join()
Question 3
With which python code can we measure the length of the list x?
A
sort(x)
B
len(x)
C
find(x)
D
measure(x)
E
list(x)
Question 4
If we have an empty if statement, we should use ... not to have an error.
A
else
B
pass
C
continue
D
break
E
elif
Question 5
What is the output of this python code?
i = 0
list1 = []
while i < 10:
  if i%2==0:
    list1.append(i)
  i += 1
print(list1)
A
[0, 1, 2, 3, 4, ,5 6, 7, 8]
B
[2, 4, 6, 8]
C
[0, 2, 4, 6]
D
[0, 2, 4, 6, 8]
E
[1, 2, 3, 4, ,5 6, 7, 8]
Question 6
What is the Output of This Python Code?
a = 10
b = 2
c = 5
print((c*a-a*b)%b)
A
0
B
4
C
2
D
3
E
1
Question 7
What is the output of this python code?
list1 = ["cat", "Dog", "bird", "lion", "bear"]
list1.sort(key = str.lower)
print(list1)
A
['lion', 'cat', 'bear', 'Dog', 'bird']
B
['lion', 'bear', 'Dog', 'bird', 'cat']
C
['lion', 'cat', 'bird', 'bear', 'Dog', ]
D
['bear', 'Dog', 'bird', 'cat', 'lion']
E
['bear', 'bird', 'cat', 'Dog', 'lion']
Question 8
What is the output of this python code?
list = [4,6,7,2,8]
list.remove(6)
print(list.index(7))
A
4
B
1
C
2
D
0
E
3
Question 9
What is the output of this code?
list = [10, ["aa", "bb", ["life", "is", "good"], "cc"], 33]
print(list[1][2][0][0])
A
l
B
d
C
i
D
o
E
g
Question 10
To check if each word start with an upper case letter in a string, we use ... method.
A
isupper()
B
isalpha()
C
isdecimal()
D
isspace()
E
istitle()
Question 11
What is the Output Of This Python Math Code?
import math
def myfunction(x,y):
   return math.sqrt(x**y)
print(myfunction(2,6))
A
4.0
B
12.0
C
16.0
D
20.0
E
8.0
Question 12
Which dictionary method is used to compare two dictionaries?
A
union()
B
len()
C
chc()
D
str()
E
cmp()
Question 13
What is the output of this python code?
list1 = []
i = 0
while i < 6:
  i += 1
  if i == 3:
    continue
  list1.append(i)
print(list1)
A
[1, 2, 3, 4, 5]
B
[1, 2, 4, 5]
C
[3]
D
[1, 2, 4, 5, 6]
E
[1, 2, 3, 4, 5, 6]
Question 14
Which one can not be a Python Variable Name?
A
abc
B
_abc_
C
20abc
D
none of them
E
abc1abc2
Question 15
How to access to the second character in the below string?
A
"Hello"[-1]
B
"Hello"[1]
C
"Hello"[2]
D
"Hello"[-2]
E
"Hello"[0]
Question 16
What is the result of this python code?
numbers1 = {12,56,80}
numbers2 = {12,17,56,80,92}
print(numbers1.issubset(numbers2))
A
None of them
B
{12,17,56,80,92}
C
True
D
False
E
{12,56,80}
Question 17
How to access "wolf" item in list x? 
x= ["eagle","bear","wolf"]
A
x[1]
B
x[3]
C
x[-1]
D
x[0]
E
x[-2]
Question 18
How to call function MyFunc?
A
MyFunc():
B
set MyFunc()
C
MyFunc()
D
MyFunc();
E
get MyFunc()
Question 19
What is the result of this python code?
numbers=(5,12,25,33,48,50,61)
for x in numbers:
  if x % 5 == 0 and x % 10 == 0:
    print(x)
  else:
    continue
A
5,25,50
B
50
C
25,50
D
5,12,25,33,48,50,61
E
25
Question 20
How to convert [1, 2, 7, 8] to [1, 2, 3, 4, 5, 6, 7, 8]? (List a)
A
a[2:] = [3, 4, 5, 6]
B
a[2:2] = [3, 4, 5, 6]
C
a[3:2] = [3, 4, 5, 6]
D
a[0:2] = [3, 4, 5, 6]
E
a[:3] = [3, 4, 5, 6]
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