reffec.com

ANSWERS TO SELF REVIEW EXERCISES in Microsoft Office Attach QRCode in Microsoft Office ANSWERS TO SELF REVIEW EXERCISES

ANSWERS TO SELF REVIEW EXERCISES use none none writer toprint none in none Microsoft Windows Official Website 6.1 a) Comm none for none on Gateway Interface. b) methods, headers.

c) domain name server (DNS). d) MIME type. e) Environment variables.

f) cgi.escape. g) QUERY_STRING.

h) standard output. i) os.environ.

j) forms.. pythonhtp1_06.fm Page 223 Saturday, December 8, 2001 1:27 PM 6 . Introductio n to the Common Gateway Interface (CGI). 6.2 a) True none for none . b) False.

Function ctime.time takes a floating-point value that represents the number of seconds since the epoch as an argument and returns a human-readable string representing the current time. c) True.

d) False. A question mark acts as a delimiter between the resource and the query string in a URL. e) False.

The server executes CGI scripts. f) False. The Status: 204 No Response header indicates that, although the request was successful, the browser should continue to display the same page.

g) True. h) True. i) True.

j) False. Form data can be stored in an object of class cgi.FieldStorage.

. EXERCISES 6.3 Write a none for none CGI script that prints the squares of the integers from 1 to 10 on separate lines. 6.

4 Modify your solution to Exercise 6.3 to display its output in an XHTML table. The left column should be the number, and the right column should be the square of that number.

6.5 Write a CGI script that receives as input three numbers from the client and returns a statement indicating whether the three numbers could represent an equilateral triangle (all three sides are the same length), an isosceles triangle (two sides are the same length) or a right triangle (the square of one side is equal to the sum of the squares of the other two sides). 6.

6 Write a soothsayer CGI program that allows the user to submit a question. When the question is submitted, the server should display a random response from a list of vague answers. 6.

7 You are provided with a portal page (see the code and output below) where people can buy products. Write the CGI script to enable this interactive portal. The user should specify how many of each item to buy.

The total cost of the items purchased should be displayed to the user.. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26. <!DOCTYP none none E html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <!-- Exercise 6.7: ex06_07.

html --> <!-- Interactive portal that compiles shopping list based --> <!-- on user input. --> <html> <head> <title>Buy Something</title> </head> <body> <h1>Clearance!</h1> <p>Please enter how many of each product you would like to order into the box in the right-hand column.</p> <form method = "post" action = "http://localhost/cgi-bin/ex06_07.

py"> <table width = "100%" border = "3"> <tr> <th>Product Name</th> <th>Description</th> <th>Price</th> <th>Order</th> </tr>. pythonhtp1_06.fm Page 224 Saturday, December 8, 2001 1:27 PM Introductio none none n to the Common Gateway Interface (CGI). 6 . 27 28 29 30 none for none 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52. <tr> <td>CD</td> <td>Buy this really cool CD</td> <td>$12.00</td> <td><input type = "text" name = "CD" /></td> </tr> <tr> <td>Book</td> <td>Buy this really cool book</td> <td>$19.99</td> <td><input type = "text" name = "book" /></td> </tr> <tr> <td>Airplane</td> <td>Buy this really cool airplane</td> <td>$1,000,000</td> <td><input type = "text" name = "airplane" /></td> </tr> </table> <input type = "submit" value = "submit"> </form> </body> </html>.

6.8 Write a none for none CGI script for a TV show survey. List five TV shows, let the survey participant rank the TV shows with numbers from 1 (least favorite) to 5 (most favorite).

Display the participant"s most favorite TV show.. pythonhtp1_07.fm Page 225 Saturday, December 8, 2001 2:29 PM Object-Based Programming Objectives To unders none none tand the software-engineering concepts of encapsulation and data hiding. To understand the notions of data abstraction and abstract data types (ADTs). To create Python ADTs, namely classes.

To understand how to create, use and destroy objects of a class. To control access to object attributes and methods. To begin to appreciate the value of object orientation.

. My object a ll sublime I shall achieve in time. W. S.

Gilbert Is it a world to hide virtues in William Shakespeare, Twelfth Night Your public servants serve you right. Adlai Stevenson Classes struggle, some classes triumph, others are eliminated. Mao Zedong This above all: to thine own self be true.

William Shakespeare, Hamlet.
Copyright © reffec.com . All rights reserved.