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
How to access "wolf", "lion" and "tiger" items in list x? 
x= ["eagle","bear","wolf", "lion", "tiger"]
A
x[3:]
B
x[2:]
C
x[:2]
D
x[2:3]
E
x[-1:2]
Question 2
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
{12,17,56,80,92}
C
{17,22,80}
D
{22, 56, 12, 92}
E
{12,17,17,22,56,80,80,92}
Question 3
With which python method, we replace some part of a string?
A
change()
B
replace()
C
convert()
D
strip()
E
sort()
Question 4
What is the output of this code?
try:
  a=5
  print(a)
except:
  print("An Error!")
else:
  print("All is Good!")
A
An Error!
B
All is Good!
C
5
D
Exception
E
5 All is Good!
Question 5
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]
B
[5, 10, 15, 20, 25]
C
[0, 5, 10, 15, 20, 25, 30]
D
[5, 10, 15, 20, 25, 30]
E
[0, 5, 10, 15, 20, 25]
Question 6
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, 7], 4]
B
[1, [2, 3], 4] [1, [2, 3], 4]
C
none of them
D
[1, [2, 7], 4] [1, [2, 3], 4]
E
[1, [2, 7], 4] [1, [2, 7], 4]
Question 7
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, 3]
D
[4, 6, 7, 2, 8]
E
[4, 6, 7, 3, 2, 8]
Question 8
What is the Output Of This Python Math Code?
import math
print(math.sqrt((pow(5,2)-5)*5))
A
15.0
B
20.0
C
30.0
D
25.0
E
10.0
Question 9
Which symbol is used for comments in python?
A
/
B
*
C
//
D
#
E
-
Question 10
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
180
D
60
E
100
Question 11
What is the maximum value for an integer in Python 3?
A
65536
B
0
C
16512
D
32767
E
no limit
Question 12
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, 2, 3, 4, 5, 6, 7, 8, 9]
B
[1, 3, 5, 7, 9]
C
[1, 4, 9, 16, 25, 36, 49, 64, 81]
D
[1, 100]
E
[1, 10]
Question 13
What is the result of this code?
import math
print(round(12.5)-round(10.7))
A
4
B
1
C
0
D
3
E
2
Question 14
What is the output of this code?
msg = "Welcome to python course!"
x = msg.index("python")
print(x)
A
10
B
12
C
11
D
9
E
8
Question 15
How to create a function named FirstFunction?
A
set FirstFunction():
B
create FirstFunction()
C
create FirstFunction():
D
def FirstFunction()
E
def FirstFunction():
Question 16
How to access the last item in the list x?
A
x[-%]
B
x[1]
C
x[-]
D
x[-1]
E
x[ ]
Question 17
If statement, without indentation rises error.
A
True
B
False
Question 18
... block lets you test a block of code for errors.
A
raise
B
except
C
finally
D
none of them
E
try
Question 19
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
none of them
C
{2,3,7,10,15}
D
{1,2,3}
E
{10, 15, 7}
Question 20
What is the Output of This Python Code?
a = 5
b = 2
c = 3
print((b**a-a*c)%b)
A
2
B
0
C
4
D
3
E
1
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.