Lecture 2.1 (Tuesday, Jan. 27)


  • A0 in!
  • A1 is now out - the Shakespeare Browser


We spent most of our time on Python data structures, the last part of these notes. We'll visit the HTML and URL material on Thursday.

Python and Flask and HTML

We're going to talk more about HTML.

Review the basic page:

<!doctype html>
<title>Hello, world</title>
<p>The world is greeted.</p>

There are ways that we want to structure the document.

h1, h2, …
These are heading tags. There are 6 of them for different levels of headings.
This is a paragraph. Does what it says on the tin. Usually has some space around it.
This is a generic block-level element - use this when you need a block, but there isn't something more meaningful to use.
ul and ol
Lists (unordered and ordered).

HTML is divided into block elements, like those above, and inline elements:

anchor, used to make links
emphasis (generally italics)
strong emphasis (generally bold)
describe a piece of code (usually set in typewriter font)
a generic inline element

Let's review URLs:


The URL points to a page.

URL stands for Uniform Resource Locator. A URL is a form of URI, or Uniform Resource Identifier. There are a few other kinds of URIs, but we won't see them much.

You can see the URL in your browser address bar.

We can hyperlink to URLs.

URLs are mapped to functions in Flask, to files in web servers.

  • Show this off with my web site
  • Show off some pages doing things

Python and data structures


In class we did a number of Python examples. Consult the notebook with comments for that.

So far we've seen some basic Python code.

review Flask app from last week

Data in Python takes several forms:

  • Strings
  • Numbers
  • Booleans
  • None
  • Lists — they're like arrays, but you can change their size. We use these a lot.
  • Dictionaries — hash tables, they let us store things by key
  • Other object types

Everything in Python is an object, but that doesn't matter too much to us right now.


a_string = 'foo'
a_number = 3
a_bool = False
a_list = ['foo', 'apple', 7]
a_dict = {'name': 'hackem muche', 'type': 'identify'}

Show off data structure actions in IPython Notebook.

Then move to Jinja if we have time