Академический Документы
Профессиональный Документы
Культура Документы
Sat, Nov 4
Agenda
Python
Jinja
SQL
Problem Set 7
Python Terminology
Class: A user-defined prototype for an object (~ struct)
Modules: ~ Library
self.name = name
__init__() is a special method,
self.salary = salary which is called class constructor
or initialization method that Python
Employee.empCount += 1
calls when you create a new
instance of this class.
e.g. jakub = Employee(“jason”,
def displayCount(self):
10000)
print "Total Employee %d" % Employee.empCount
func(a, b)
print(a + b)
print(a * b)
execute(add, 2, 4) # 6
execute(mult, 2, 4)# 8
Decorators
decorators are functions which are used to modify the
behaviour of other functions
return func() + 1
print(one()) # 2 print(one()) # 2
Style in Python
PEP8
User submits a request (URL) => reaches controller
Controller uses the Model retrieve all of the information it needs from the
database
The controller action uses the models to retrieve all of the necessary
data from a database, places the data in an array, and loads a view,
passing along the data structure.
The view accesses the structure of data and uses it to render the
requested page, which is then presented to the user in their
browser.
Jinja
NULL
INTEGER
REAL
TEXT
BLOB
Some notes
Unlike in C, the CHAR data type in SQL does not refer to a single
character. Rather, it is a fixed-length string. In most relational
databases, including MySQL, you actually specify the fixed-length
as part of the type definition, e.g. CHAR(10).
INSERT
SELECT
UPDATE
DELETE
SQL
INSERT INTO <table>(<columns>)VALUES(<values>)
SELECT
<columns>FROM<table>WHERE<condition>ORDER
BY<column>
SELECT
<columns>FROM<table1>JOIN<table2>ON<predicate>
Type of rows?
Error checking?
Supervised Learning
Unsupervised Learning
http://scikit-learn.org/stable/modules/neighbors.html
Feedback!
http://tinyurl.com/cs50withchi