Source Python Course 3

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Looking at the following XML, what text value would we find at path "/a/c/e" <a> <b>X</b> <c> <d>Y</d> <e>Z</e> </c> </a> A/Z B/a C/e D/Y E/b

A

How are strings stored internally in Python 3? A/Unicode B/ASCII C/UTF-8 D/EBCDIC E/Byte Code

A

If you were building an XML Schema and wanted to limit the values allowed in an xs:string field to only those in a particular list, what XML tag would you use in your XML Schema definition? A/xs:enumeration B/xs:complexType C/xs:sequence D/xs:element E/maxOccurs

A

In this Python code, which line actually reads the data? 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() A/mysock.recv() B/socket.socket() C/mysock.close() D/mysock.connect() E/mysock.send()

A

Question 1 What is "serialization" when we are talking about web services? A/The act of taking data stored in a program and formatting it so it can be sent across the network B/Sorting all the data stored in a tuple C/Making it so that dictionaries can maintain their keys in sorted order D/Marking each network packet so it can be put back into order on the receiving system

A

Question 1 Which of the following Python data structures is most similar to the value returned in this line of Python: x=urllib.request.urlopen('http://data.pr4e.org/romeo.txt') A/file handle B/list C/dictionary D/socket E/regular expression

A

Question 1 Who is credited with the REST approach to web services? A/Roy Fielding B/Bjarne Stroustrup C/Vint Cerf D/Leonard Klienrock E/Daphne Koller

A

Question 4 In a client-server application on the web using sockets, which must come up first? A/server B/client C/it does not matter

A

Question 4 In this Python code, which line is most like the open() call to read a file: 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() A/mysock.connect() B/import socket C/mysock.recv() D/mysock.send() E/socket.socket()

A

Question 7 What library call do you make to append properly encoded parameters to the end of a URL like the following: http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=Ann+Arbor%2C+MI A/urllib.parse.urlencode() B/re.encode() C/re.match() D/urllib.urlcat()

A

Question 9 What does the "Z" mean in this representation of a time: 2002-05-30T09:30:10Z A/This time is in the UTC timezone B/The hours value is in the range 0-12 C/The local timezone for this time is New Zealand D/This time is Daylight Savings Time

A

What ends up in the "x" variable in the following code: html = urllib.request.urlopen(url).read() soup = BeautifulSoup(html, 'html.parser') x = soup('a') A/A list of all the anchor tags (<a..) in the HTML from the URL B/True if there were any anchor tags in the HTML from the URL C/All of the externally linked CSS files in the HTML from the URL D/All of the paragraphs of the HTML from the URL

A

What is the decimal (Base-10) numeric value for the upper case letter "G" in the ASCII character set? A/71 B/7 C/103 D/25073 E/14

A

What is the difference between the "+" and "*" character in regular expressions? A/The "+" matches at least one character and the "*" matches zero or more characters B/The "+" matches upper case characters and the "*" matches lowercase characters C/The "+" matches the beginning of a line and the "*" matches the end of a line D/The "+" matches the actual plus character and the "*" matches any character D/The "+" indicates "start of extraction" and the "*" indicates the "end of extraction"

A

What is the method to cause Python to parse XML that is stored in a string? A/fromstring() B/parse() C/readall() D/extract() E/xpath()

A

What kind of variable will you get in Python when the following JSON is parsed: [ "Glenn", "Sally", "Jen" ] A/A list with three items B/A dictionary with three key / value pairs C/A dictionary with one key / value pair D/Three tuples E/One Tuple

A

When you click on an anchor tag in a web page like below, what HTTP request is sent to the server? <p>Please click <a href="page1.htm">here</a>.</p> A/GET B/POST C/PUT D/DELETE E/INFO

A

Which of the following TCP sockets is most commonly used for the web protocol (HTTP)? A/80 B/25 C/22 D/119 E/23

A

Which of the following dates is in ISO8601 format? A/2002-05-30T09:30:10Z B/05/30/2002 C/2002-May-30 D/May 30, 2002

A

Which of the following is most like an open socket in an application? A/An "in-progress" phone conversation B/Fiber optic cables C/The wheels on an automobile D/The chain on a bicycle E/The ringer on a telephone

A

Which of the following regular expressions would extract 'uct.ac.za' from this string using re.findall? From [email protected] Sat Jan 5 09:14:16 2008 A/@(\S+) B/@\S+ C/F.+: D/..@\S+..

A

Which of the following regular expressions would extract the URL from this line of HTML: <p>Please click <a href="http://www.dr-chuck.com">here</a></p> A/href="(.+)" B/href=".+" C/http://.* D/<.*>

A

Which of these two web service approaches is preferred in most modern service-oriented applications? A/REST - Representational state transfer B/SOAP - Simple Object Access Protocol

A

Question 2 What Python library do you have to import to parse and handle JSON? A/import re B/import json C/BeautifulSoup D/ElementTree

B

What character do you add to the "+" or "*" to indicate that the match is to be done in a non-greedy manner? A/$ B/? C/\g D/** E/^ F/++

B

What happens when you exceed the Google geocoding API rate limit? A/You canot use the API until you respond to an email that contains a survey question B/You cannot use the API for 24 hours C/The API starts to perform very slowly D/Your application starts to perform very slowly

B

What is an important aspect of an Application Layer protocol like HTTP? A/How much memory does the server need to serve requests? B/Which application talks first? The client or server? C/What is the IP address for a domain like www.dr-chuck.com? D/How long do we wait before packets are retransmitted?

B

What is the most common Unicode encoding when moving data between systems? A/UTF-64 B/UTF-8 C/UTF-128 D/UTF-32 E/UTF-16

B

What is the purpose of the BeautifulSoup Python library? A/It builds word clouds from web pages B/It repairs and parses HTML to make it easier for a program to understand C/It allows a web site to choose an attractive skin D/It optimizes files that are retrieved many times E/It animates web operations to make them more attractive

B

What would the following mean in a regular expression? [a-z0-9] A/Match anything but a lowercase letter or digit B/Match a lowercase letter or a digit C/Match an entire line as long as it is lowercase letters or digits D/Match any number of lowercase letters followed by any number of digits E/Match any text that is surrounded by square braces

B

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? A/find() B/decode() C/trim() D/upper() E/encode()

B

Which HTTP header tells the browser the kind of document that is being returned? A/HTML-Document: B/Content-Type: C/Metadata: D/ETag: E/Document-Type:

B

Which of the following is true about an API? A/An API defines the header bits in the first 8 bits of all IP packets B/An API is a contract that defines how to use a software library C/An API keeps servers running even when the power is off D/An API defines the pin-outs for the USB connectors

B

. Question 3 What is the method used to parse a string containing JSON data so that you can work with the data in Python? A/json.parse() B/json.connect() C/json.loads() D/json.read()

C

Question 10 Which organization publishes Internet Protocol Standards? A/SIFA B/LDAP C/IETF D/IMS E/SCORM

C

What do we call it when a browser uses the HTTP protocol to load a file or page from a server and display it in the browser? A/Internet Protocol (IP) B/SMTP C/The Request/Response Cycle D/DECNET E/IMAP

C

What does the "[0-9]+" match in a regular expression? A/Zero or more digits B/Any number of digits at the beginning of a line C/One or more digits D/Any mathematical expression E/Several digits followed by a plus sign

C

What is the type of the return value of the re.findall() method? A/A string B/An integer C/A list of strings D/A single character E/A boolean

C

What kind of variable will you get in Python when the following JSON is parsed: { "id" : "001", "x" : "2", "name" : "Chuck" } A/A list of tuples B/A list with three items C/A dictionary with three key / value pairs D/A tuple with three items E/A list with six items

C

What separates the HTTP headers from the body of the HTTP document? A/Four dashes B/X-End-Header: true C/A blank line D/A less-than sign indicating the start of an HTML tag

C

What will the '\$' regular expression match? A/The beginning of a line B/An empty line C/A dollar sign D/A new line at the end of a line E/The end of a line

C

In this XML, which are the "complex elements"? <people> <person> <name>Chuck</name> <phone>303 4456</phone> </person> <person> <name>Noah</name> <phone>622 7421</phone> </person> </people> A/name B/phone C/people D/person E/Noah

CD

Given the following line of text: From [email protected] Sat Jan 5 09:14:16 2008 What would the regular expression '\S+?@\S+' match? A/[email protected] B/marquard@uct C/\@\ D/[email protected] E/From

D

In the following XML, which node is the parent node of node e <a> <b>X</b> <c> <d>Y</d> <e>Z</e> </c> </a> A/b B/a C/e D/c

D

Question 1 Who is credited with getting the JSON movement started? A/Pooja Sankar B/Mitchell Baker C/Bjarne Stroustrup D/Douglas Crockford

D

Question 5 Which of the following is not true about the service-oriented approach? A/Standards are developed where many pairs of applications must work together B/Web services and APIs are used to transfer data between applications C/An application makes use of the services provided by other applications D/An application runs together all in one place

D

What does the "H" of HTTP stand for? A/Manual B/Hyperspeed C/Simple D/HyperText E/wHolsitic

D

What header does Twitter use to tell you how many more API requests you can make before you will be rate limited? A/x-max-requests B/content-type C/x-request-count-down D/x-rate-limit-remaining

D

What is a good time zone to use when computers are exchanging data over APIs? A/The local time zone of the receiving computer B/The local time zone of the sending computer without daylight savings time C/The local time zone of the sending computer D/Universal Time / GMT

D

What is the "wild card" character in a regular expression (i.e., the character that matches any character)? A/$ B/? C/^ D/. E/+ F/*

D

What is the ASCII character that is associated with the decimal value 42? A/^ B// C/! D/* E/+

D

What is the purpose of XML Schema? A/A Python program to tranform XML files B/To compute SHA1 checksums on data to make sure it is not modified in transit C/To transfer XML data reliably during network outages D/To establish a contract as to what is valid XML

D

What should you check before scraping a web site? A/That the web site only has links within the same site B/That the web site supports the HTTP GET command C/That the web site returns HTML for all pages D/That the web site allows scraping

D

Which of the following best describes "Regular Expressions"? A/A way to solve Algebra formulas for the unknown value B/A way to calculate mathematical values paying attention to operator precedence C/The way Python handles and recovers from errors that would otherwise cause a traceback D/A small programming language unto itself

D

Question 4 In the following XML, which are attributes? <person> <name>Chuck</name> <phone type="intl"> +1 734 303 4456 </phone> <email hide="yes" /> </person> A/name B/email C/person D/hide E/type

DE

For this XML Schema: <xs:complexType name="person"> <xs:sequence> <xs:element name="lastname" type="xs:string"/> <xs:element name="age" type="xs:integer"/> <xs:element name="dateborn" type="xs:date"/> </xs:sequence> </xs:complexType> And this XML, <person> <lastname>Severance</lastname> <Age>17</Age> <dateborn>2001-04-17</dateborn> </person> . Question 8 For this XML Schema: 1 2 3 4 5 6 7 <xs:complexType name="person"> <xs:sequence> <xs:element name="lastname" type="xs:string"/> <xs:element name="age" type="xs:integer"/> <xs:element name="dateborn" type="xs:date"/> </xs:sequence> </xs:complexType> And this XML, <person> <lastname>Severance</lastname> <Age>17</Age> <dateborn>2001-04-17</dateborn> </person> Which tag is incorrect? A/age B/person C/dateborn D/lastname E/Age

E

Question 6 If the following JSON were parsed and put into the variable x { "users": [ { "status": { "text": "@jazzychad I just bought one .__.", }, "location": "San Francisco, California", "screen_name": "leahculver", "name": "Leah Culver", }, ... what Python code would extract "Leah Culver" from the JSON? A/x["name"] B/x["users"]["name"] C/x[0]["name"] D/x->name E/x["users"][0]["name"]

E

What are the three parts of this URL (Uniform Resource Locator)? http://www.dr-chuck.com/page1.htm A/Host, offset, and page B/Page, offset, and count C/Protocol, document, and offset D/Document, page, and protocol E/Protocol, host, and document

E

What does the following Python sequence print out? x = 'From: Using the : character' y = re.findall('^F.+:', x) print(y) A/['From:'] B/^F.+: C/: D/From: E/['From: Using the :']

E

What must you do in Python before opening a socket? A/_socket = true B/import tcp-socket C/import tcp D/open socket E/import socket

E

What protocol does Twitter use to protect its API? A/PKI-HMAC B/SHA1-MD5 C/SOAP D/Java Web Tokens E/OAuth F/WS*Security .

E

What word does the following sequence of numbers represent in ASCII: 108, 105, 110, 101 A/tree B/lost C/func D/ping E/line

E


संबंधित स्टडी सेट्स

Chapter 11 Nervous System and Nervous Tissue

View Set

Basic Coding-Ch.50 (I feel bad love, I feel sad love, Sometimes happy love)

View Set

Interpersonal Communication Midterm

View Set