Статус: [object Object]
1 балл
5.
Вопрос 5
Каков результат следующих нескольких строк кода?
123
for i, x in enumerate(['A', 'B', 'C']):
print(i, 2 * x)
0 AA
1 BB
2 CC
0 A
1 B
2 C
1 AA
2 BB
3 CC
0 A
2 B
4 C
Статус: [object Object]
1 балл
6.
Вопрос 6
Каков результат выполнения следующих строк кода?
12
class Points(object):
def init(self, x, y):
self.x = x
self.y = y
def print_point(self):
print('x=', self.x, ' y=', self.y)
p2 = Points(1, 2)
p2.x = 'A'
x=A y=A
x= A y=2
x= 1 y=2
x=A, y=B
Статус: [object Object]
1 балл
7.
Вопрос 7
Учитывая функцию дельта, когда следующая функция вернет значение 1?
123456
def delta(x):
if x == 0:
y = 1
else:
y = 0
return y
Когда на вход подается любое значение, кроме 0
Никогда
Когда на входе 1
Когда на входе 0
Статус: [object Object]
1 балл
8.
Вопрос 8
Каков результат следующих строк кода
123456789
a = 1
def do(x):
return x + a
print(do(1))
1
Assistant
Here are the answers to the quiz questions concerning HTTP responses, web scraping, data structures, plotting libraries, and HTML tags:
1. Question 1
The three parts of a response message are:
Start or status line, headers, and body
2. Question 2
The line of code table_row = table.find_all(name='tr') in web scraping:
Finds all data in the table marked with the tag "tr"
3. Question 3
The data structure commonly used by HTTP responses to return data is:
JSON
4. Question 4
The Python library used for plotting is:
matplotlib
5. Question 5
The role of the 'td' tag in HTML files is:
Table data cell
The 'td' tag is used to define a cell in a table.
0
NameError: имя 'a' не определено.
2
Статус: [object Object]
1 балл
9.
Вопрос 9
Какие две из следующих функций выполнят сложение двух чисел с минимальным количеством переменных? [Выберите две]
def add(a, b):
return(a + b)
def add(a, b):
return(sum(a, b))
def add(a, b):
return(sum((a, b)))
def add(a, b):
c = a+b
return(c)
Статус: [object Object]
1 балл
10.
Вопрос 10
Рассмотрите следующий код:
1234567
try:
numerator = 10
denominator = 0
result = numerator / denominator
print(result)
except ZeroDivisionError:
print("Error: Denominator cannot be 0.")
Что из нижеперечисленного является правильным ожидаемым результатом?
10/0
Ошибка: Знаменатель не может быть равен 0
NaN
ZeroDivisionError
Статус: [object Object]
1 балл
Assistant: Here are the answers to the Python quiz questions:
1. Question 1
The output is:
Go
Mike
2. Question 2
The result is:
True
x > -5 evaluates to True because 1 is greater than -5.
3. Question 3
The output is:
5
4
3
The loop continues until x becomes 2.
4. Question 4
The code doesn't print anything. The Points class is defined, but no instance of it is created and its print_point method is not called. To get an output, you'd need something like:
p1 = Points('A', 'B')
p1.print_point()
This would print x= A y= B
5. Question 5
The output is:
0 AA
1 BB
2 CC
enumerate provides both the index and the value. The code then prints the index and the value repeated twice.
6. Question 6
The output is:
x= A y= 2
The line p2.x = 'A' modifies the x attribute of the p2 object after it's created.
7. Question 7
The function will return 1 when:
When the input is 0
8. Question 8
The output is:
2
The function do uses the global variable a.
9. Question 9
The two functions that perform addition with the minimum number of variables are:
def add(a, b): return(a + b)
def add(a, b): return(sum((a, b))) (While sum uses a tuple, it is still considered minimal variable usage in this context)
10. Question 10
The correct expected output is:
Error: Denominator cannot be 0.
The try...except block catches the ZeroDivisionError and prints the error message.
User: Solve this quiz
Вопрос 1
Какой результат дадут следующие строки кода?
a=np.array([0,1])
b=np.array([1,0])
np.dot(a,b)
1
array([[0, 0], [0, 0]])
0
array([1,1])
Статус: [object Object]
1 балл
2.
Вопрос 2
Каким станет значение Z после выполнения следующего кода?
X=np.array([[1,0],[0,1]])
Y=np.array([[0,1],[1,0]])
Z=X+Y
array([[0, 0], [0, 0]])
array([[0,1],[1,1]])
array([[1,1],[1,1]])
array([[1,0],[0,1]])
Статус: [object Object]
1 балл
3.
Вопрос 3
Если Вы выполните следующие строки кода, какие значения будет принимать переменная 'out'?
X=np.array([[1,0,1],[2,2,2]])
out=X[0:2,2]
array([0,2])
array([1,1])
array([1,2])
array([1,0])
Статус: [object Object]
1 балл
4.
Вопрос 4
После выполнения приведенного кода, какое значение будет иметь Z?
X=np.array([[1,0],[0,1]])
Y=np.array([[2,1],[1,2]])
Z=np.dot(X,Y)
array([[1,0],[0,1]])
array([[2,0],[1,0]])
array([[3,1],[1,3] ])
array([[2,1],[1,2] ])
Статус: [object Object]
1 балл
5.
Вопрос 5
Рассмотрим следующий текстовый файл: Example1.txt: