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