CS5nm, Fall 2008

ex14: testing for type


 

Goals for this exercise

By the time you have completed this exercise, you should be able to

Step by Step Instructions

Step 0: Getting Started


Step 0a: Download the starting point code from the ex14 folder

You should find a folder ex14 in the usual place on the web site. Here is a direct link:

ex14/ex14PhillConrad.py

If it is not there, ask your TA or instructor for help.

 

Step 1: Replace the stub in the isTuple() function

Run the sample code given (ex14PhillConrad.py). Note that some of the tests fail. This is because the isTuple() function is written with a stub:

def isTuple(x):
   return False # @@@ STUB... Replace this line with correct value @@@

If you are not sure what a stub is, review Step 2c of ex5.

Your task: replace the stub with code that works

To figure out how to do this, study the function isList() which appears earlier in the file. Also examine the tests that go along with it.

This should tell you what you need to do to make this function work properly.

What NOT do to...

Note that you should NOT make the tests pass by leaving the stub in place, and simply change all the "expect" values in the tests to False. That will make all the test pass, but is it NOT the way to proceed.

When the stub is replaced and the (unmodified) tests pass, proceed to Step 2.


Step 2: Write an isString function

Write a similar function called isString that is modeled on the isList and isTuple functions. You should provide:

Step 3: Submitting on GauchoSpace

Before submitting on Gauchospace:


Evaluation and Grading (80 pts)

Grading Rubric:

5 pts: naming and submitting file correctly
5 pts: correct header comment
20 pts: correctly fixing the isTuple function so that all the tests pass
20 pts: correctly writing an isString function
10 pts: adding the consumes/produces comment
10 pts: removing all the @@@ comments

Due Date: Wed 11/26/2008 (5pm)

Ex12 is due Wednesday 11/26 at 5pm (before Thanksgiving break).

Please note that there is no lab meeting on Wednesday 11/26. We will meet for lecture at 1pm, although attendance will not be taken that day—but we will not meet for lab. If you have questions about the assignment that you would normally bring to office hours or lab, bring them to lecture on 11/26 at 1pm.

Since there is no lab on 11/26, ex14 will be accepted through Tue 12/02 at 7pm without penalty—however there are no extensions beyond that date. So, if you have questions, come to office hours on Thursday 11/20, Tuesday 11/25, class on Wednesday 11/26, or office hours on Tuesday 12/02. After that, it will be too late for ex14.


Copyright 2008, Phillip T. Conrad, CS Dept, UC Santa Barbara. Permission to copy for non-commercial, non-profit, educational purposes granted, provided appropriate credit is given; all other rights reserved.