Governor's Career & Technical Academy Arlington

CSC 221 Weekly Assignments: Week 6

CSC 221


Overview

This week will finish Chapter 5: Functions, and begin planning for the PCEP certification.

Wednesday, October 2nd

Classwork

After class on Monday, our co-teacher Chris mentioned to me that the solution I shared for lots_of_letters:

def lots_of_letters(word):
    s = ''
    for i in range(1, len(word) + 1):
        s += i * word[i-1]
    return s

Could be improved:

def lots_of_letters(word):
    s = ''
    for index, letter in enumerate(word):
        s += (index + 1) * letter 
    return s

Study this example. It is indeed a big improvement over the first solution, since it is clearly more pythonic. Python can be a beautiful language, especially in the hands of programmers who know how to use it.

We will start class today with presentations by Gizelle and Erij of the replace function from excercise set 2 exercise 7, and by Chris and Antoan of the find_mode function from exercise set 0 exercise 9.

After that I want to present a few short topics inspired by a conversation I had with Lucy in class last Thursday:

Homework

Complete all the exercise in Chapter 5 Exercise Set 5: PCEP Practice in preparation for a quiz based on these exercises at the beginning of class next Monday.

Monday, September 30th

Classwork / Homework

Due to the unplanned interruption of class last Thursday, we will play catch up today. I will start things off with the promised presentation on exception handling in Python.

Then the four students who did make it to class last Thursday will present the exercises they chose in class that day. Everyone else will pair up and choose exercises to present in class on Wednesday.

Lucy and Lary will share their solution to exercise set 1, practice set 2, exercise 5: sum_of_squares_of_digits. Delaine and Sean F. will share their solution to exercise set 2, doctest practice set 3, exercise 2: lots_of_letters.