Coursera Using python to access Web data quiz 4

来源:互联网 发布:c语言编程器下载 编辑:程序博客网 时间:2024/05/22 03:21



1
point
1。

Which of the following Python data structures is most similar to the value returned in this line of Python:

1
x = urllib.request.urlopen('http://data.pr4e.org/romeo.txt')

socket

regular expression

dictionary

file handle

list

1
point
2。

In this Python code, which line actually reads the data?

1
2
3
4
5
6
7
8
9
10
11
12
13
import socket
mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
mysock.connect(('data.pr4e.org', 80))
cmd = 'GET http://data.pr4e.org/romeo.txt HTTP/1.0\n\n'.encode()
mysock.send(cmd)
while True:
data = mysock.recv(512)
if (len(data) < 1):
break
print(data.decode())
mysock.close()

mysock.recv()

socket.socket()

mysock.close()

mysock.connect()

mysock.send()

1
point
3。

Which of the following regular expressions would extract the URL from this line of HTML:

1
<p>Please click <a href="http://www.dr-chuck.com">here</a></p>

href="(.+)"

href=".+"

http://.*

<.*>

1
point
4。

In this Python code, which line is most like the open() call to read a file:

1
2
3
4
5
6
7
8
9
10
11
12
13
import socket
mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
mysock.connect(('data.pr4e.org', 80))
cmd = 'GET http://data.pr4e.org/romeo.txt HTTP/1.0\n\n'.encode()
mysock.send(cmd)
while True:
data = mysock.recv(512)
if (len(data) < 1):
break
print(data.decode())
mysock.close()

mysock.connect()

import socket

mysock.recv()

mysock.send()

socket.socket()

1
point
5。

Which HTTP header tells the browser the kind of document that is being returned?

HTML-Document:

Content-Type:

Document-Type:

ETag:

Metadata:

1
point
6。

What should you check before scraping a web site?

That the web site returns HTML for all pages

That the web site supports the HTTP GET command

That the web site allows scraping

That the web site only has links within the same site

1
point
7。

What is the purpose of the BeautifulSoup Python library?

It builds word clouds from web pages

It allows a web site to choose an attractive skin

It optimizes files that are retrieved many times

It animates web operations to make them more attractive

It repairs and parses HTML to make it easier for a program to understand

1
point
8。

What ends up in the "x" variable in the following code:

1
2
3
html = urllib.request.urlopen(url).read()
soup = BeautifulSoup(html, 'html.parser')
x = soup('a')

A list of all the anchor tags (<a..) in the HTML from the URL

True if there were any anchor tags in the HTML from the URL

All of the externally linked CSS files in the HTML from the URL

All of the paragraphs of the HTML from the URL

1
point
9。

What is the most common Unicode encoding when moving data between systems?

UTF-32

UTF-64

UTF-16

UTF-128

UTF-8

1
point
10。

What is the decimal (Base-10) numeric value for the upper case letter "G" in the ASCII character set?

71

7

103

25073

14

1
point
11。

What word does the following sequence of numbers represent in ASCII:

108, 105, 110, 101

lost

tree

ping

line

func

1
point
12。

How are strings stored internally in Python 3?

Byte Code

UTF-8

ASCII

EBCDIC

Unicode

1
point
13。

When reading data across the network (i.e. from a URL) in Python 3, what method must be used to convert it to the internal format used by strings?

decode()

upper()

find()

trim()

encode()

1
point
1。

Which of the following Python data structures is most similar to the value returned in this line of Python:

1
x = urllib.request.urlopen('http://data.pr4e.org/romeo.txt')

socket

regular expression

dictionary

file handle

list

1
point
2。

In this Python code, which line actually reads the data?

1
2
3
4
5
6
7
8
9
10
11
12
13
import socket
mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
mysock.connect(('data.pr4e.org', 80))
cmd = 'GET http://data.pr4e.org/romeo.txt HTTP/1.0\n\n'.encode()
mysock.send(cmd)
while True:
data = mysock.recv(512)
if (len(data) < 1):
break
print(data.decode())
mysock.close()

mysock.recv()

socket.socket()

mysock.close()

mysock.connect()

mysock.send()

1
point
3。

Which of the following regular expressions would extract the URL from this line of HTML:

1
<p>Please click <a href="http://www.dr-chuck.com">here</a></p>

href="(.+)"

href=".+"

http://.*

<.*>

1
point
4。

In this Python code, which line is most like the open() call to read a file:

1
2
3
4
5
6
7
8
9
10
11
12
13
import socket
mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
mysock.connect(('data.pr4e.org', 80))
cmd = 'GET http://data.pr4e.org/romeo.txt HTTP/1.0\n\n'.encode()
mysock.send(cmd)
while True:
data = mysock.recv(512)
if (len(data) < 1):
break
print(data.decode())
mysock.close()

mysock.connect()

import socket

mysock.recv()

mysock.send()

socket.socket()

1
point
5。

Which HTTP header tells the browser the kind of document that is being returned?

HTML-Document:

Content-Type:

Document-Type:

ETag:

Metadata:

1
point
6。

What should you check before scraping a web site?

That the web site returns HTML for all pages

That the web site supports the HTTP GET command

That the web site allows scraping

That the web site only has links within the same site

1
point
7。

What is the purpose of the BeautifulSoup Python library?

It builds word clouds from web pages

It allows a web site to choose an attractive skin

It optimizes files that are retrieved many times

It animates web operations to make them more attractive

It repairs and parses HTML to make it easier for a program to understand

1
point
8。

What ends up in the "x" variable in the following code:

1
2
3
html = urllib.request.urlopen(url).read()
soup = BeautifulSoup(html, 'html.parser')
x = soup('a')

A list of all the anchor tags (<a..) in the HTML from the URL

True if there were any anchor tags in the HTML from the URL

All of the externally linked CSS files in the HTML from the URL

All of the paragraphs of the HTML from the URL

1
point
9。

What is the most common Unicode encoding when moving data between systems?

UTF-32

UTF-64

UTF-16

UTF-128

UTF-8

1
point
10。

What is the decimal (Base-10) numeric value for the upper case letter "G" in the ASCII character set?

71

7

103

25073

14

1
point
11。

What word does the following sequence of numbers represent in ASCII:

108, 105, 110, 101

lost

tree

ping

line

func

1
point
12。

How are strings stored internally in Python 3?

Byte Code

UTF-8

ASCII

EBCDIC

Unicode

1
point
13。

When reading data across the network (i.e. from a URL) in Python 3, what method must be used to convert it to the internal format used by strings?

decode()

upper()

find()

trim()

encode()

阅读全文
0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 胳膊扭了肿了怎么办 胖人走路磨大腿怎么办 脖子上长了个淋巴结怎么办 面部危险三角区长痘痘怎么办 儿童脖子上有淋巴结节怎么办 左侧颈根部淋巴结肿大怎么办 人的三角区肿了怎么办 刮三角区肿了怎么办 乳腺增生引起的腋窝淋巴结怎么办 右边脸比左边脸大怎么办 六个月宝宝脖子有点歪怎么办 大人的头偏了怎么办 宝宝脖子睡偏了怎么办 宝宝头歪向左边怎么办 一岁宝宝头歪怎么办 宝宝头往右边歪怎么办 八个月宝宝头歪怎么办 宝宝头往左边偏怎么办 11月婴儿歪脖子怎么办 婴儿头往左边偏怎么办 宝宝头网的高怎么办 宝宝头歪向一边怎么办 2岁宝宝头睡偏了怎么办 6岁儿童头有点歪怎么办 宝宝脖子有点偏左边歪怎么办 宝宝脖子偏了怎么办呢 斜颈导致的脸歪怎么办 斜颈手术后脸部还不对称怎么办 宝宝3个月斜颈怎么办 一岁八个月宝宝斜颈怎么办 四个月宝宝有点斜颈怎么办 一岁宝宝有点偏怎么办 6个月宝宝有点斜颈怎么办 四个月宝宝左侧胸锁乳突肌厚怎么办 脖子疼好几天了怎么办 有双下巴怎么办才能瘦掉 胃突然疼的厉害怎么办 手劳损痛的厉害怎么办 手臂扭到了很疼怎么办 寒湿导致肩膀痛怎么办 吃辣脖子肿了怎么办