1 Getting Ready For Final Exam
1.1 List Operations
1.2 Skills Review Beginning
1.2.1 Python Programming Syntax
1.2.2 Python Functions
1.3 Question 1 sample final exam questions
1.4 Question 2 sample final exam questions
1.5 Clicker Assessment
1.6 Version : 2014/ 03/ 03

CS 110X Feb 28 2014

Lecture Path: 22
Back Next

Clicker: Assessment

We learn by doing
Aristotle

1 Getting Ready For Final Exam

Several students have asked about an existing function in the random module that allows you to shuffle a list.

>>> list = range(10) >>> list [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> import random >>> random.shuffle(list) >>> list [7, 6, 5, 2, 1, 4, 9, 8, 3, 0]

This might be helpful when working with randomized trials, for example.

1.1 List Operations

Yesterday we saw the basic operations for sequences. Lists go further by adding operations to manipulate a list.

These same operations apply to lists, because lists can be treated as a sequence. Lists are special, however, and have additional operations, which we will summarize tomorrow.

1.2 Skills Review Beginning

1.2.1 Python Programming Syntax
1.2.2 Python Functions

1.3 Question 1 sample final exam questions

Question 1 on the final will give you a chance to demonstrate your Python skills. Specifically, in small "sound bites" you will identify the value of a given expression. I find these very useful in quickly targeting the skills I assume you know.

Starting with the following variable definitions

>>> values = [1, 10, 9, 13, 2, 5] >>> x = 3 >>> y = 5 >>> s = ’trial and error’

What is the value of these expressions? You can try them out by hand and verify them using IDLE or the Canopy Editor.

Now that we have used a number of functions that operate directly on lists, I ask slightly different questions (as you can see by reviewing the sample final exam from last year in the class Study Guide).

1.4 Question 2 sample final exam questions

If we get here, this question is a programming question that you are to complete. The following question is just a bit more challenging than what I would have on an exam:

Write a function onlyDuplicates that takes a list of values and returns a new list that only contains those elements which appear more than once in the original list

>>> myList = [1, 3, 2, 1, 4, 5, 2] >>> onlyDuplicates(myList) [1, 2]

Note: there are two approaches you could follow to solve this function. We’ll discuss (at least) these two tomorrow.

1.5 Clicker Assessment

Clicker Assessment to be given now.

1.6 Version : 2014/03/03

(c) 2014, George Heineman