Designing Python Solutions

A Case Study Approach

CHAPTERS


Mountain Landscape

Check That Number!

More and more activities are controlled by numbers every day. Now we have numeric codes to get money, to register for class, to access a phone company, to arm an alarm system, or to use a copy machine. Computers often validate these numbers. This case study describes a program that validates numbers for a copy machine.

Resort

Banners With CLASS

From ancient times banners have proclaimed events and advertised opportunities. Computers allow individuals to create personalized banners of varied sizes and styles. This program prints block versions of six letters in user-specified sizes using the letters PYTHON. It can be altered to create banners with such messages.

Mountain Landscape

The Calendar Shop

Keeping track of time is a major industry. Historically, calendars have defined weeks and months quite differently from today. This program will create a calendar for any given year. It can be altered to create fantasy calendars without Mondays and historical calendars with 10-day weeks or 28-day months.

Resort

Roman Calculator Construction

Calculators have revolutionized mathematics, making hand computation of square roots obsolete. This program will control a calculator that takes a Roman numeral and converts it to its decimal equivalent. The program should assume that the input consists of one line, containing (only) a legal Roman numeral less than 3999.

Mountain Landscape

Is It Legal?

How should programs respond to illegal data? Assuming that data will be legal asks for trouble: What if users mistype? What if users want to confuse the program? This case study describes how to guard against illegal data in the Check That Number!, Banners With CLASS, Calendar Shop, and Roman Calculator Construction programs.

Resort

Space Text

Computers now make desktop publishing possible. Publishing software allows users to display text in much the same way as it is displayed in books. This case study describes the development of a procedure that could be inserted into a word-processing program to display text flush with the right and left margins.

Mountain Landscape

You Are What You Eat

The current enthusiasm for choosing a healthy diet motivates people to keep track of the calories, fat, and cholesterol they consume. Suppose you were asked to design a program to help. This case study describes how a programmer might respond. The program keeps track of the fat and calories and figure out daily averages, and stuff like that.

Resort

You Forgot What You Ate

The user of the You Are What You Eat program has more trouble recalling what he ate than anticipated. He also wonders if the computer can keep track of the fat and calories in each thing he eats so that he only has to enter it once. This case study describes how a programmer might respond to problems encountered by users.

Mountain Landscape

Chess Challenges

Computer programs that play chess, solve chess puzzles, or create chess problems are widespread. There is even an annual contest pitting chess playing programs against each other and against human experts. This case study addresses a simple problem related to chess, where each square either is empty or contains a queen.

Resort

The Shuffler's Dilemma

Anyone can shuffle cards by hand; getting a computer to do it takes talent. Should the computer imitate a human shuffler or behave like a machine? How can the results of a shuffle be evaluated? This case study describes programs implementing several different shuffling algorithms and compares the results.

Mountain Landscape

Roman Calculator Repair

How do you know that a program works? Julius Caesar Enterprises has constructed a program they claim will convert Roman numerals to their decimal equivalents. See if it works, fix it if it fails, and submit a bill for consultant services. The programmer also shows you the program's output for a number of test cases.

Resort

The Eating Club

Whole groups of people want to keep track of what they eat and to compare progress. This case study describes extensions to the You Are What You Eat and You Forgot What You Ate programs to handle a complex food list, multiple users, and several reporting formats. The program should be able to sort foods and entries and do it quickly.