Python programming exercises, I

Grid Computing Competence Center

Python programming exercises, I

Riccardo Murri Grid Computing Competence Center, Organisch-Chemisches Institut, University of Zurich

Nov. 10, 2011

Today's class

Getting your feet wet with Python programming. (Review of yesterday's stuff.) These slides are available for download from:

Python II

R. Murri, Large Scale Computing Infrastructures, Nov. 10, 2011

Yesterday's homework

Write a function sp(C,L) that returns a pair (tuple) of elements from a list L whose sum is integer C. (Unspecified: what should it do when no pairs of values from L sums to C?)

Python II

R. Murri, Large Scale Computing Infrastructures, Nov. 10, 2011

Testing solutions

Rather than inspecting each solutions' code, we shall write a test class, using Python standard library unit testing facility. Your solution is correct if it passes the test.

Python II

R. Murri, Large Scale Computing Infrastructures, Nov. 10, 2011

Python's unittest module

Python's unittest requires one to define a subclass of unittest.TestCase. All methods whose name starts with test are executed; if none errors out, the test is passed. Test methods should use methods assertEqual, assertTrue, etc. defined by class TestCase to check if test conditions are satisfied. Reference:

Python II

R. Murri, Large Scale Computing Infrastructures, Nov. 10, 2011

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download