rec12 - CS 177 Week 12 Recitation Slides Advanced Text...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
1 CS 177 Week 12 Recitation Slides Advanced Text Techniques and Making Text for the Web + (some examII questions)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Q21. Suppose you have the following string: str = "Purdue University" Which of the following statements will produce the same result of str.find("e")? A) str.find("e",6) B) str.find("e",0,len(str)) C) str.rfind("e") D) str.find("x") B)
Background image of page 2
3 Q22. Consider the following list: myList = ["A", "B", "C", "D", "A"] what is the output of the following statements? >>> myList.remove("A") >>> print myList A) ['B', 'C', 'D'] B) ['A','B', 'C', 'D', 'A'] C) ['B', 'C', 'D', 'A'] D) [] C)
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 Q23. Suppose that the file myFile.txt contains the following: CS177 Exam Purdue University And you have the following function read() def read(): file = open("myFile.txt", "rt") content = file.read() print content What is the output of the call to the function read()? A) ['CS177 Exam\n', 'Purdue University'] B) CS177 Exam Purdue University C) CS177 Exam Purdue University D) myFile.txt CS177 Exam Purdue University B)
Background image of page 4
HyperText Transfer Protocol (HTTP) HTTP defines a very simple protocol for how to exchange information between computers. It defines the pieces of the communication. What resource do you want? Where is it? Okay, here’s the type of thing it is (JPEG, HTML, whatever), and here it is. And the words that the computers say to one another: Not-complex words … like “GET”, “PUT” and “OK” 5
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 Uniform Resource Locators (URL) URLs allow us to reference any material anywhere on the Internet. Strictly speaking, any computer providing a protocol is accessible via a URL. Just putting your computer on the Internet does not mean that all of your files are accessible to everyone on the Internet. URLs have four parts: The protocol to use to reach this resource, The domain name of the computer where the resource is, The path on the computer to the resource, And the name of the resource .
Background image of page 6
7 Opening a URL and reading it >>> import urllib >>> connection = urllib.urlopen("http://www.ajc.com/weather") >>> weather = connection.read() >>> connection.close()
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
8 Getting the temperature live def findTemperatureLive(): # Get the weather page import urllib #Could go above, too connection=urllib.urlopen("http://www.aj
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/22/2012 for the course CS 177 taught by Professor Staff during the Fall '08 term at Purdue.

Page1 / 36

rec12 - CS 177 Week 12 Recitation Slides Advanced Text...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online