Homework 1

[Note: this webpage last modified Friday, 04-Feb-2011 19:44:51 EST]

This assignment will be handed out at the end of class on Wednesday, August 25 and is due by midnight on Tuesday August 31.

  1. (10 points)

    Give Python commands to compute and print the average of four numbers that are stored in variables x1, x2, x3, and x4.

  2. (10 points)

    Give Python/JES commands to ask the user for the name of a picture, then display the picture on the screen, and finally print that the picture has been displayed.

  3. (10 points)

    Give Python commands to set a variable named n to some value and then display the remainder of n divided by 2, n divided by 3, and n divided by 5.

  4. (20 points)

    Recall that a computer stores integers by viewing a sequence of bits as a binary number. For example, 0011, might represent the number 3.

    Recall also that a computer stores text by interpreting a sequence of numbers (one stored in each byte) as letters. For example, using the ASCII code, the letter 'a' is stored as the number 97, the letter 'b' is stored as the number 98 and so on.

    So we have an idea how the computer stores numbers and text as bits. Explain at a high level how a computer might store an html web page. In other words, what encoding should the computer use for interpreting a sequence of bits as a web page? How does the computer know what size font the user wants, whether to underline or not, etc.?

    You can explain what you think the file format of a web page should look like. If you prefer, you can explain the file format that web pages actually uses. Either way, just explain in a few sentences the basic idea.