What will be the output of the following code?
import re
string = 'bat, lat, mat, bet, let, met, bit, lit, mit, bot, lot, mot'
result = re.findall('b[ao]t', string)
print(result)
Quiz 1 coursera python
Quiz
•
Professional Development
•
1st - 5th Grade
•
Medium
Orazbaı Seıitmaģambet
Used 1+ times
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following code?
import re
string = 'bat, lat, mat, bet, let, met, bit, lit, mit, bot, lot, mot'
result = re.findall('b[ao]t', string)
print(result)
'bat, bot'
['bat', 'bot']
'bat, bet, bit, bot'
['bat', 'bet', 'bit', 'bot']
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Assume a and b are two (20, 20) numpy arrays. The L2-distance (defined above) between two equal dimension arrays can be calculated in python as follows:
def l2_dist(a, b):
result = ((a - b) * (a - b)).sum()
result = result ** 0.5
return result
l2_dist(a.T, b.T)
l2_dist(np.reshape(a, (20 20)), np.reshape(b, (20 20, 1)))
l2_dist(np.reshape(a, (20 20)), np.reshape(b, (20 20)))
l2_dist(a, b)
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider the following variables in Python:
a1 = np.random.rand(4)
a2 = np.random.rand(4, 1)
a3 = np.array([[1, 2, 3, 4]])
a4 = np.arange(1, 4, 1)
a5 = np.linspace(1 ,4, 4)
Which of the following statements regarding these variables is correct?
a5. shape == a1. shape
a4. ndim() == 1
a3. shape == a4. shape
al. shape == a2. shape
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is the correct output for the code given below?
import numpy as np
old = np. array([[1, 1, 1], [1, 1, 1]])
new = old
new[0, : 2] = 0
print (old)
[[1 1 1] [1 1 1]]
[[0 0 1] [1 1 1]]
[[1 1 0][1 1 0]]
[[0 1 1][0 1 1]]
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Given the 6x6 NumPy array r shown below, which of the following options would slice the shaded elements?
r[[2, 3], [2, 3]]
r [2: 4, 2: 4]
r[[2, 4], [2, 4]]
r[2: 3, 2: 3]
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
import re
s = ACBСAC"
For the given string, which of the following regular expressions can be used to check if the string starts with 'AC'?
re. findall(' [^A]C', s)
re. findall(' ^AC', s)
re. findall(' AC', s)
re.findall('^[AC]', s)
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the variable L after the following code is executed?
import re
s = 'ACAABAACAAAB'
result = re.findall('A{1,2}', s)
L = len(result)
8
12
5
4
9 questions
Suszarki PerfectCare
Quiz
•
1st - 3rd Grade
7 questions
Zlecenia dla kontraktu - powtórka
Quiz
•
3rd Grade
9 questions
GESTION DOCUMENTAL
Quiz
•
1st Grade
12 questions
obiekty techniczne- kartkówka3
Quiz
•
4th Grade
10 questions
struktury społeczne
Quiz
•
1st - 4th Grade
10 questions
Produkcja papieru
Quiz
•
1st - 3rd Grade
15 questions
Repaso dietoterapia_ud4
Quiz
•
3rd Grade
12 questions
Konwencja ATP
Quiz
•
1st - 10th Grade
15 questions
Multiplication Facts
Quiz
•
4th Grade
20 questions
Math Review - Grade 6
Quiz
•
6th Grade
20 questions
math review
Quiz
•
4th Grade
5 questions
capitalization in sentences
Quiz
•
5th - 8th Grade
10 questions
Juneteenth History and Significance
Interactive video
•
5th - 8th Grade
15 questions
Adding and Subtracting Fractions
Quiz
•
5th Grade
10 questions
R2H Day One Internship Expectation Review Guidelines
Quiz
•
Professional Development
12 questions
Dividing Fractions
Quiz
•
6th Grade
15 questions
Multiplication Facts
Quiz
•
4th Grade
20 questions
math review
Quiz
•
4th Grade
5 questions
capitalization in sentences
Quiz
•
5th - 8th Grade
10 questions
Juneteenth History and Significance
Interactive video
•
5th - 8th Grade
15 questions
Adding and Subtracting Fractions
Quiz
•
5th Grade
18 questions
Main Idea & Supporting Details
Quiz
•
5th Grade
5 questions
Basement Basketball
Quiz
•
3rd Grade
20 questions
Parts of Speech
Quiz
•
3rd - 6th Grade