Write a function called riddle that returns a two line string, with a riddle and its answer. Modify makeHomePage to insert the riddle at the end of the page rather than the tagline.

Note: This simply involves changing the tagline method on page 368 to be about riddles instead.


```
import urllib
import random

def makeHomePage(name,interests):
file=open(getMediaPath("homepage.html"),"wt")
file.write( doctype ())
file.write(title(name+"'s Home Page"))
text = "

Welcome to "+name+"'s Home Page

"
text += "

Hi! I am "+name+". This is my home page!"
text += " I am interested in "+interests+"

"
text += "

Random riddle of the day: "+riddle()+"

"
file.write(body(text))
file.close()
def riddle():
riddles = []
riddles += ["What can you catch, but not hold?\nA cold."]
riddles += ["What belongs to you but others use it more?\nYour name."]
riddles += ["What kind of stones are never found in the ocean?\nDry ones."]
riddles += ["What do elves do after school?\nGnomework."]
riddles += ["Why did the chicken cross the road?\nTo get to the other side."]
return random.choice(riddles)
```

Computer Science & Information Technology

You might also like to view...

_________ is an advantage of using Linux as the basis for an embedded OS.

A) ?Vendor independence ? B) ?Varied hardware support C) ?Low cost ? D) ?All of the above

Computer Science & Information Technology

Implement the Modify a Forum option in default.pl such that individual messages can be deleted. Selecting this option should display the initial screen, but with each forum name followed by a hyperlink to a script named modForum.pl. Script modForum.pl should display the messages as in forum.pl, but each message title should be followed by a link to a script named del- Post.pl, which removes the given message from the current forum. [Hint: Look at the getElementsByTagName, removeChild, and item methods described in the XML::DOM documentation.]

What will be an ideal response?

Computer Science & Information Technology

To save an existing document with a new name, use the New command on the File menu.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

Which of the following is true of web-based development??

A. ?Web-based software treats the software as a product that is more dependent on desktop computing powers and resources. B. ?Web-based software usually requires middleware to communicate with existing software and legacy systems. C. ?Web-based systems can run on multiple hardware environments. D. ?When companies acquire web-based software as a service rather than a product they purchase, they can limit in-house involvement to a minimum.

Computer Science & Information Technology