Download - Introductory Programming With Python
![Page 1: Introductory Programming With Python](https://reader035.vdocument.in/reader035/viewer/2022062312/5552c057b4c90581158b46f5/html5/thumbnails/1.jpg)
Introductory Programming with
PythonBrendan McCane
![Page 2: Introductory Programming With Python](https://reader035.vdocument.in/reader035/viewer/2022062312/5552c057b4c90581158b46f5/html5/thumbnails/2.jpg)
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.
![Page 3: Introductory Programming With Python](https://reader035.vdocument.in/reader035/viewer/2022062312/5552c057b4c90581158b46f5/html5/thumbnails/3.jpg)
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.
![Page 4: Introductory Programming With Python](https://reader035.vdocument.in/reader035/viewer/2022062312/5552c057b4c90581158b46f5/html5/thumbnails/4.jpg)
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?
![Page 5: Introductory Programming With Python](https://reader035.vdocument.in/reader035/viewer/2022062312/5552c057b4c90581158b46f5/html5/thumbnails/5.jpg)
Design Principles
• As simple as possible
• Few magical incantations
• Immediate feedback (no compile/run cycle)
• A practical and modern language
![Page 6: Introductory Programming With Python](https://reader035.vdocument.in/reader035/viewer/2022062312/5552c057b4c90581158b46f5/html5/thumbnails/6.jpg)
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
![Page 7: Introductory Programming With Python](https://reader035.vdocument.in/reader035/viewer/2022062312/5552c057b4c90581158b46f5/html5/thumbnails/7.jpg)
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
![Page 8: Introductory Programming With Python](https://reader035.vdocument.in/reader035/viewer/2022062312/5552c057b4c90581158b46f5/html5/thumbnails/8.jpg)
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
![Page 9: Introductory Programming With Python](https://reader035.vdocument.in/reader035/viewer/2022062312/5552c057b4c90581158b46f5/html5/thumbnails/9.jpg)
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
![Page 10: Introductory Programming With Python](https://reader035.vdocument.in/reader035/viewer/2022062312/5552c057b4c90581158b46f5/html5/thumbnails/10.jpg)
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
![Page 11: Introductory Programming With Python](https://reader035.vdocument.in/reader035/viewer/2022062312/5552c057b4c90581158b46f5/html5/thumbnails/11.jpg)
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
"""
![Page 12: Introductory Programming With Python](https://reader035.vdocument.in/reader035/viewer/2022062312/5552c057b4c90581158b46f5/html5/thumbnails/12.jpg)
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)]
![Page 13: Introductory Programming With Python](https://reader035.vdocument.in/reader035/viewer/2022062312/5552c057b4c90581158b46f5/html5/thumbnails/13.jpg)
Outcomes
![Page 14: Introductory Programming With Python](https://reader035.vdocument.in/reader035/viewer/2022062312/5552c057b4c90581158b46f5/html5/thumbnails/14.jpg)
Outcomes
• 172 students attended first lab
• 28% A
• 23% B
• 22% C
• 27% failed (19% failed terms)
![Page 15: Introductory Programming With Python](https://reader035.vdocument.in/reader035/viewer/2022062312/5552c057b4c90581158b46f5/html5/thumbnails/15.jpg)
![Page 16: Introductory Programming With Python](https://reader035.vdocument.in/reader035/viewer/2022062312/5552c057b4c90581158b46f5/html5/thumbnails/16.jpg)
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”
![Page 17: Introductory Programming With Python](https://reader035.vdocument.in/reader035/viewer/2022062312/5552c057b4c90581158b46f5/html5/thumbnails/17.jpg)
![Page 18: Introductory Programming With Python](https://reader035.vdocument.in/reader035/viewer/2022062312/5552c057b4c90581158b46f5/html5/thumbnails/18.jpg)
![Page 19: Introductory Programming With Python](https://reader035.vdocument.in/reader035/viewer/2022062312/5552c057b4c90581158b46f5/html5/thumbnails/19.jpg)
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)
![Page 20: Introductory Programming With Python](https://reader035.vdocument.in/reader035/viewer/2022062312/5552c057b4c90581158b46f5/html5/thumbnails/20.jpg)
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