Which module in Python supports regular expressions?
reregexpyregexWhich of the following creates a pattern object?
re.create(str)re.regex(str)re.compile(str)re.assemble(str)What does the function re.match do?
What does the function re.search do?
What will be the output of the following Python code?
sentence = 'we are humans'
matched = re.match(r'( .* ) ( .*? ) ( .* )', sentence)
print(matched.groups())
('we', 'are', 'humans')(we, are, humans)('we', 'humans')'we are humans'What will be the output of the following Python code?
sentence = 'we are humans'
matched = re.match(r'( .* ) ( .*? ) ( .* )', sentence)
print(matched.group())
('we', 'are', 'humans')(we, are, humans)('we', 'humans')'we are humans'What will be the output of the following Python code?
sentence = 'we are humans'
matched = re.match(r'( .* ) ( .*? ) ( .* )', sentence)
print(matched.group(2))
'are''we''humans''we are humans'What will be the output of the following Python code?
sentence = 'horses are fast'
regex = re.compile('(?P<animal>\\w+) (?P<verb>\\w+) (?P<adjective>\\w+)')
matched = re.search(regex, sentence)
print(matched.groupdict())
{'animal': 'horses', 'verb': 'are', 'adjective': 'fast'}('horses', 'are', 'fast')'horses are fast''are'What will be the output of the following Python code?
sentence = 'horses are fast'
regex = re.compile('(?P<animal>\\w+) (?P<verb>\\w+) (?P<adjective>\\w+)')
matched = re.search(regex, sentence)
print(matched.groups())
{'animal': 'horses', 'verb': 'are', 'adjective': 'fast'}('horses', 'are', 'fast')'horses are fast''are'What will be the output of the following Python code?
sentence = 'horses are fast'
regex = re.compile('(?P<animal>\\w+) (?P<verb>\\w+) (?P<adjective>\\w+)')
matched = re.search(regex, sentence)
print(matched.group(2))
{'animal': 'horses', 'verb': 'are', 'adjective': 'fast'}('horses', 'are', 'fast')'horses are fast''are'Which of the following is not an HTTP method that can change some state on the server?
response = requests.put( ... )response = requests.post( ... )response = requests.delete( ... )response = requests.copy( ... )Which module in Python supports XML?
Data Frame Merging
Given the dictionaries:
Car_Price = {'Company': ['Toyota', 'Honda', 'BMV', 'Audi'],
'Price': [23845, 17995, 135925, 71400]}
car_Horsepower = {'Company': ['Toyota', 'Honda', 'BMV', 'Audi'],
'horsepower': [141, 80, 182, 160]}
Which of the following approaches correctly creates two data frames, merges them on the "Company" column, and appends the second data frame as a new column so that the final (expected) output is:
| index | Company | Price | horsepower |
|---|---|---|---|
| 0 | Toyota | 23845 | 141 |
| 1 | Honda | 17995 | 80 |
| 2 | BMV | 135925 | 182 |
| 3 | Audi | 71400 | 160 |
pd.DataFrame() on each dictionary and merge using pd.merge(df1, df2, on="Company")pd.concat([df1, df2], axis=1)df1.join(df2.set_index('Company'), on='Company')HTTP Request Execution
Which snippet correctly executes an HTTP GET request to:
https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=9&cad=rja&uact=8?
```python
import requests
response = requests.get("<https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=9&cad=rja&uact=8>")
```
CSV and XML Representation