Class Notes (1,000,000)
CA (620,000)
SFU (10,000)
CMPT (500)
Lecture 8

CMPT 165 Lecture Notes - Lecture 8: Newline, Autocomplete, Code Reuse


Department
Computing Science
Course Code
CMPT 165
Professor
Greg Baker
Lecture
8

This preview shows pages 1-3. to view the full 69 pages of the document.
CMPT 165
Unit 8 Advanced Programming - Part 2
Dec. 1st, 2015

Only pages 1-3 are available for preview. Some parts have been intentionally blurred.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Note #1
2
# MIME: must be declared in the first line
a_markup_str ="""Content-type: text/html
<html>
<head>
<title>My first web script</title>
</head>
<body>
<h1>My first web script</h1>
<p>This is a dynamically generated web page.</p>
</body>
</html>
"""
print( a_markup_str )

Only pages 1-3 are available for preview. Some parts have been intentionally blurred.

Ways to string-formatting…
1. Use commas to combine different data types
3
>>> print("Hey daddy, does 2 x 2 equal to", 2*2, "?")
Hey daddy, does 2 x 2 equal to 4 ?
2. Use of escape characters:
See more here: https://docs.python.org/2.0/ref/strings.html
# approach 1
print( "Content-type: text/html")
print()
# approach 2
print( "Content-type: text/html \n") # newline
# other examples:
print( "\t<p>Hello!</p>") # tab
You're Reading a Preview

Unlock to view full version