introductory programming with python

Post on 13-May-2015

1.420 Views

Category:

Education

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

Describes a first year introductory programming course using Python and some of the student outcomes of the course.

TRANSCRIPT

Introductory Programming with

PythonBrendan McCane

Hitchhiker’s Guide to Programming

Programming is hard. You just won’t believe how vastly, hugely, mind-bogglingly hard it is. I mean, you may think making a decent sandwich is hard, but that’s just peanuts to programming.

Donald Knuth says:

In fact, my main conclusion after spending ten years of my life working on the TEX project is that software is hard.

CS1

• Average failure rate for CS1 courses is 33% (min 0%, max 60%).

• Most universities teach Java, C# or C++.

• Industrially relevant and OO is more “natural” right?

Design Principles

• As simple as possible

• Few magical incantations

• Immediate feedback (no compile/run cycle)

• A practical and modern language

Target Audience

• Students majoring in computer science– Python in semester 1 (optional)– Java in semester 2 (compulsory)

• Students not majoring in computer science– Mostly science or technical majors

Curriculum

• We modified an open source textbook

• How to Think Like a Computer Scientist

• You can download our version from:– http://www.cs.otago.ac.nz/staffpriv/mccane/te

aching.html

Curriculum

• Introduction• Variables, expressions• Python builtins• Functions (2)• Conditionals• More functions• Test Driven Development• Files and modules• Iteration (2)

• GUI programming• Case study (2)• Strings (2)• Lists (2)• Tuples and sets• Dictionaries• System Programming• OOP• Case study

Course Structure

• Tight integration between lectures and laboratories

• 24 lectures, 21 laboratories

• Terms requirement – students had to submit 18 labs (not marked)

• Labs had basic + advanced exercises

• Lectures were programming demonstrations

Assessment

• Mid-semester test (20%) – multi-choice

• Final Exam (60%) – multi-choice

• Mastery tests (2 x 10%)– Programming problems under test conditions– Tests published beforehand– 4 sections per test, each worth 2.5%– Each section pass/fail– Graded based on doctests + code inspection

Mastery Test Example (lab 9)

def score(numbers):

"""

give the average of the numbers excluding the biggest

and smallest one

>>> score([2, 7, 9, 10, 13, 1, 5, 12])

7.5

>>> score([3, 7, 2.5, -4])

2.75

"""

Final Exam Example

def matrix_to_sparse(in_matrix):

sparse = {}

for row_index,row in enumerate(in_matrix):

for col_index,val in enumerate(row):

if val != 0:

sparse[(row_index,col_index)] = val

return sparse

matrix = [[0,0,1], [0,2,0], [3,0,0]]

sparse = matrix_to_sparse(matrix)

print sparse[(2,0)], sparse[(1,1)], sparse[(0,2)]

Outcomes

Outcomes

• 172 students attended first lab

• 28% A

• 23% B

• 22% C

• 27% failed (19% failed terms)

Notable Comments

• Easy topics: first half

• Hard topics: second half

• Best aspect: labs

• I would like to change: “a move away from extensive use of programming”

• “F*%! Matrices”

Statistical Results

• Java with Python better than Java without (p=0.001)

• Java 2009 better than Java 2008 (p=0.0007)

• Java without Python (2009) not better than Java 2008 (p=0.18)

Conclusions

• Python is a joy to teach

• Learning Python is a good pre-cursor for learning Java

• Open source textbooks are fantastic

• Mastery tests are masterful

• Force students to attend labs

top related