Iteration

In this assignment students are asked to respond to "customer requests" such as writing a program which shows the effects of compounded interest as well as developing an algorithm for the number of times a digit appears in different numbers.

Selection Statements- Responding to Customer Requests

In this assignment students are asked to respond to two customer requests. First they must create a program to analyze the body mass index of Olympic athletes. Second, they are asked to create a calculator script which helps with errors.

First Program

In this assignment students create functions to perform calculations in Python. Using data related to driving a car and time, students must create functions that tell the user how many miles-per-gallon or the total number of milliseconds occur within a particular day. This assignment is ideal for students who want more practice creating functions and calculating values.

ASCII Art

In this assignment students work either individually or in pairs to create ASCII art using loops. Students must write functions that print a rectangle, a triangle, bumps of increasing size, a diamond, and a striped diamond. In addition to requiring students to use loops, this assignment reviews basic parameter passing. It is particularly useful for students who are new to loops.

TT Securities, Incorporated

In this assignment students work either individually or in pairs to manage and analyze stock prices via a text menu. Students must write a function that asks the user what they want to do, providing nine options: input a new list of stock prices, print the current list, find various statistics, find the best day to buy/sell the stock in question, and quit the menu. Students may not use built-in functions, and must therefore write functions like sum, min, and max themselves using loops. In addition to reviewing i/o and loops, this assignment requires students to decompose their code thoughtfully. It is particularly useful for students who are new to loops and need additional practice with decomposition.

Pi from pie

In this assignment students work either individually or in pairs to estimate pi with a Monte Carlo simulation. Students simulate throwing darts at a square with a circle inscribed in the middle by generating random pairs of (x, y) coordinates, keeping track of the ratio of darts that hit the circle. They must write two functions: one that throws a given number of darts, and one that continues throwing darts until the estimated value for pi is within a given tolerance. This assignment reviews random number generation and loops, as well as requiring students to adequately comment and decompose their code. It is particularly useful for students who need additional practice with loops.

Looks Good!

In this assignment students work either individually or in pairs to write a series of image-processing functions. Using list comprehension, students must write functions that invert the colors of an image, change the colors to greyscale, change the image to black and white, flip the image, and mirror the image. Students are also encouraged to be creative and come up with their own alterations. This assignment covers list comprehension on multidimensional lists. It is particularly useful for students who are new to multidimensional lists and need additional practice using list comprehension on them.

Conversions and Compressions

In this assignment students work either individually or in pairs to write functions that convert between different bases and compress/decompress black and white images. Students must write functions that convert between bases between 2 and 10 and that add binary numbers. They must also write a basic compression/decompression algorithm for black and white images. This assignment reviews strings and requires students to use functions that they wrote earlier. It is particularly useful for students who are new to representing numbers in different bases and need additional practice with strings and recursion.

Sorting out Caesar!

In this assignment students work either individually or in pairs to write functions that encode and decode a Caesar cipher, along with several other sorting and string problems. Students must write functions that encipher a message by rotating the letters and decipher a message by looking at letter frequencies in the enciphered message. Additionally, students must write functions that sort a binary list, sort a general list, find the number of characters shared between two strings, and find the least common subsequence of two strings. In addition to requiring students to work with recursion, strings, and list comprehension, this assignment requires students to design their own algorithms. It is particularly useful for students who are comfortable with the topics covered but need additional practice designing algorithms.

The sleepwalking student

In this assignment students work to write a program that simulates a random walk. Using recursion, students must write a function that continuously randomly selects left or right and keeps track of how far the random walker has moved. They must then analyze their random walks to find how far the random walker travels on average. In addition to reviewing recursion and random number generation, this assignment requires students to create debug statements that print additional information. It is particularly useful for students who are new to recursion and need additional practice debugging.

Subscribe to HTML