This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Creator: Kai Li | |
## Time: 12/9/2012 | |
## Description: My FOAF file | |
<rdf:RDF | |
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" | |
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" | |
xmlns:foaf="http://xmlns.com/foaf/0.1/" | |
xmlns:dc="http://purl.org/dc/elements/1.1/" | |
xmlns:rrdf="http://rdfs.org/resume-rdf/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Kai Li <--- My name | |
# hello_world.py <--- Name of the file | |
# 10/15/2012 <--- Date | |
# Print the pattern to the screen. | |
a = " | | " | |
b = "--------" | |
print a | |
print b | |
print a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is Kai Li's first script for Mechanical MOOC lesson. | |
# Kai Li <--- My name | |
# hello_world.py <--- Name of the file | |
# 10/15/2012 <--- Date | |
# print "Hello, world!" to the screen | |
x = 'Hello, world!' | |
print x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Creator: Kai Li | |
## Time: 10/18/2012 | |
## Task: Print a matrix of numbers from 1*1 to 7*7. | |
## Warning: It's not functioning properly, in that after everyline, there is an unexpected "None". | |
def nal(n): | |
i = 1 | |
while i <= 7: | |
print n*i, '\t', | |
i = i + 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Creator: Kai Li | |
## time: 11/26/2012 | |
## Task: Trace all the folders and the number of files in these folders in a given URL. | |
import os.path as os | |
def myvisit(a, dir, files): | |
print dir, ": %d files" % len(files) | |
os.walk('c:/python27', myvisit, None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Creator: Kai Li | |
## Time: 11/26/2012 | |
## Task: Getting properties of all the files in a given folder. | |
import os | |
import os.path | |
import time | |
for f in os.listdir("c:\python27"): | |
print "File :", os.path.basename(f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Creator: Kai Li | |
## Time: 11/26/2012 | |
## Task: Fetching Wikipedia article using Python's "urllib2" module | |
import urllib2 | |
opener = urllib2.build_opener() | |
opener.addheaders = [('User-agent', 'Mozilla/5.0')] | |
req = opener.open("http://en.wikipedia.org/wiki/Betelgeuse") |