COSC 101 Homework 3: Fall 2014

This homework is designed to hone your skills in breaking down a problem into manageable parts and using for loops to map numbers to patterns. This homework is due on September 24, 11:55pm.

Text art

Your task is write three programs, each one drawing a particlar text-art pattern. Your text art must be scalable, meaning that the art is not a fixed sequence of characters, but a pattern that can be drawn at a variety of scales.

Each program must ask the user for a positive number and then scale the text pattern accordingly. Note that the scale captures some notion of the size of the art, but it is not necessarily equal to the width or height. For example, in the rocket, the scale is the equal to half the height of the diamond pattern on the fuselage -- this might seem like an odd choice but actually it makes the programming easier.

Write three separate programs for the following three patterns (listed in order of difficulty):

  1. Tree: http://cs.colgate.edu/~mhay/cosc101/hw/03/tree.html

    Write your program in the provided file hw3_tree.py.

  2. Volcano: http://cs.colgate.edu/~mhay/cosc101/hw/03/volcano.html

    Write your program in the provided file hw3_volcano.py.

  3. Rocket: http://cs.colgate.edu/~mhay/cosc101/hw/03/rocket.html

    Write your program in the provided file hw3_rocket.py.

Hints

Start early and come to office hours or tutor hours if you need help. Schedules for both are on moodle.

For each pattern, examine the pictures carefully, taking note of spacing and patterns.

Break each problem down into two major steps: (1) write code to draw the pattern, (2) get the pattern to scale with user input. To complete step 1, choose a scale, say scale 3, and write a program that reproduces the scale 3 pattern exactly. At this point, the program should not take any user input. Once you have this working, figure out how the pattern changes with user input.

Printing the backslash character \ is tricky because python uses the backslash to produce special characters. For example, the string "\t" is a tab and "\n" is a newline. A single backslash character is represented by a string of two backslash characters ("\\"). For example:

print "/\\/\\"

will print: /\/\

Challenge problem

Challenge problems are entirely optional extensions to the homework. If you complete them successfully, you are rewarded with a sense of accomplishment and a small number of extra points on the homework. They are intended for students who want to explore a little further; only pursue the challenge problem after you have successfully completed the homework.

For this week, you have two options.

  1. Create your own text art. Design your own scalable pattern. The amount of extra credit will depend on the level of creativity and programming difficulty. Something as easy as the tree may not receive any credit. Something as complex as the rocket can receive the maximum extra credit.
  2. Write a program that draws this stick figure pattern: http://cs.colgate.edu/~mhay/cosc101/hw/03/woman.html

Submission instructions

Please upload the three python files hw3_tree.py, hw3_volcano.py, and hw3_rocket.py to moodle. If you do the challenge problem, upload hw3_challenge.py as well.

Be sure to fill out the header on each file!

Grading

Your assignment will be graded on two criteria:

  1. Correctness: be sure that your programs produce output that is identical to the provided examples. [80% = 10 + 30 + 40]
  2. Program design and style [20%]: style and program design become increasingly important the more complex your program becomes. For these programs, adhere to the following guidelines: