teaching programming by iterative deepening dr. mark lee | [email protected] school of computer...

11
TEACHING PROGRAMMING BY ITERATIVE DEEPENING Dr. Mark Lee | [email protected] School of Computer Science, University of Birmingham http://www.cs.bham.ac.uk/~mgl/python/

Upload: johnathan-armstrong

Post on 24-Dec-2015

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: TEACHING PROGRAMMING BY ITERATIVE DEEPENING Dr. Mark Lee | m.g.lee@cs.bham.ac.uk School of Computer Science, University of Birmingham mgl/python

TEACHING PROGRAMMING BY ITERATIVE DEEPENINGDr. Mark Lee | [email protected]

School of Computer Science, University of Birmingham

http://www.cs.bham.ac.uk/~mgl/python/

Page 2: TEACHING PROGRAMMING BY ITERATIVE DEEPENING Dr. Mark Lee | m.g.lee@cs.bham.ac.uk School of Computer Science, University of Birmingham mgl/python

Some Quotes• If debugging is the process of removing software bugs,

then programming must be the process of putting them in. (Edsger Dijkstra)

• Debugging is twice as hard as writing the code in the first place. Therefore if you write your code as cleverly as possible then by definition you will be too stupid to debug it. (Brian Kernighan)

• Logic is useless – when are we going to learn something useful? Like programming games. (First year CS student on my course – now departed)

Page 3: TEACHING PROGRAMMING BY ITERATIVE DEEPENING Dr. Mark Lee | m.g.lee@cs.bham.ac.uk School of Computer Science, University of Birmingham mgl/python

IntroductionProgramming is a• Craft• Engineering (good or bad)• The application of Computer Science

In this talk I’ll give • An overview of Python• Reasons why it’s an ideal first language for kids (and adults)

But my real message is• Writing code is about

1. Recognising/Abstracting a problem

2. Designing/Recalling a solution (the algorithm)

3. Implementation (programming)

4. Debugging & improvement

• Programming cannot be isolated from the rest of computing

Page 4: TEACHING PROGRAMMING BY ITERATIVE DEEPENING Dr. Mark Lee | m.g.lee@cs.bham.ac.uk School of Computer Science, University of Birmingham mgl/python

New Computing Curriculum 2014• Computational Thinking:

• Decomposition• Pattern Recognition• Abstraction• Pattern Generalisation• Algorithm Design

(from Computing in the National Curriculum, CAS 2014)

• From the new Curriculum for KS3 • Understand several key algorithms that reflect computational thinking; use logical

reasoning to compare the utility of different algorithms for the same problem.

• “Use two or more programming languages, at least one of which is textual, to solve a variety of computational problems; make use of appropriate data structures; design and develop modular programmes that use procedures or functions.”

Page 5: TEACHING PROGRAMMING BY ITERATIVE DEEPENING Dr. Mark Lee | m.g.lee@cs.bham.ac.uk School of Computer Science, University of Birmingham mgl/python

Python• Created by Guido Van Rossum in 1991• General Purpose High Level Programming Language

• Emphasis on readability• Emphasis on consistency

• Typically succinct compared to other languages (e.g. C, Java etc.

• Python 3.4.1 (May 2014)• Dynamic Type system• Highly extendable• Typically a procedural language – but support for Object Oriented,

Functional programming styles.

Page 6: TEACHING PROGRAMMING BY ITERATIVE DEEPENING Dr. Mark Lee | m.g.lee@cs.bham.ac.uk School of Computer Science, University of Birmingham mgl/python

Code Snippets

print (“hello world”)

def shopping () : shopping_list = ['spam', "eggs", "ham"] count = 0

for item in shopping_list : print (item) count = count + 1

print ("total items is " + str(count))

Page 7: TEACHING PROGRAMMING BY ITERATIVE DEEPENING Dr. Mark Lee | m.g.lee@cs.bham.ac.uk School of Computer Science, University of Birmingham mgl/python

Python in the real world

http://blog.codeeval.com/codeevalblog/2014#.U0JQBeddV5A=

Page 8: TEACHING PROGRAMMING BY ITERATIVE DEEPENING Dr. Mark Lee | m.g.lee@cs.bham.ac.uk School of Computer Science, University of Birmingham mgl/python

More realistically …

Page 9: TEACHING PROGRAMMING BY ITERATIVE DEEPENING Dr. Mark Lee | m.g.lee@cs.bham.ac.uk School of Computer Science, University of Birmingham mgl/python

Why is Python popular?• Python cannot compete with

• Speed of C, C++, C# (games programming)• Specific technology friendliness of Javascript, VB.net, C#, Swift, Ruby on Rails etc. • Scalability and portability of Java• Higher Education Dominance of Java in undergraduate studies

(but)

• Python is • Fun• Highly readable• Quick to learn• “Good enough” for most jobs• Easy to debug• Great community• Native to Android, Raspberry PI, Linux, Apple IOS• Good stepping stone to Java (Jython) & plays well with C (Cython)

Page 10: TEACHING PROGRAMMING BY ITERATIVE DEEPENING Dr. Mark Lee | m.g.lee@cs.bham.ac.uk School of Computer Science, University of Birmingham mgl/python

Sorting Cards

• You have N cards which need to be sorted in ascending order.• Write an algorithm with the following constraints:

The cards start face down on the table The instructions must be for only one person. The person moving the cards can only have one card in each

hand at any point (i.e. she can only look at the values of two cards at one time)

The instructions can't require that the person remember the value of a card once they put it down. You can however use the space on the table however you like.

Page 11: TEACHING PROGRAMMING BY ITERATIVE DEEPENING Dr. Mark Lee | m.g.lee@cs.bham.ac.uk School of Computer Science, University of Birmingham mgl/python

Abstraction• Suppose you have a randomly sorted list of integers in the

range 1 – 52

[5,6,52,24,1,43]

• And you wish to sort them in ascending order

[1,2,3,4, … 52]