CS 150 - Prelab 8 - OPTIONAL

Due: Wednesday 4/19 at the beginning of lab

Since lab is on Wednesday this week, the prelab is optional, and nothing needs to be handed in. You are still encouraged to answer the following questions in order to prepare for lab.

Answer the following questions:

  1. What do the following two functions do (try them out)?
    import datetime
    def get_hour():
        now = datetime.datetime.now()
        return str(now.hour)
    def get_date():
        now = datetime.datetime.now()
        return str(now.month) + "-" + str(now.day) + "-" + str(now.year)
  2. What is the 4th line in the html file for this prelab? Don't write a program to do this, but instead just view the source in your browser and count down to the 4th line. To get the source, click on the "View" menu or right-click in the page, then select the option "View Source" or "View Page Source" (the name differs slightly for different browsers).

  3. In Monday's lecture, we discussed an example program called email_extractor.py. Look at this example.
    1. What does the write_list_to_file function do?
    2. What does line[begin_index:end_index] capture? You may have to run it and add some print statements to figure it out. Make sure you understand what this program does since you'll be doing something similar for the lab.

Do the following things: