CS0008 Assignment 2

Introduction

The purpose of this assignment is to give you practice writing and testing functions, problem solving, and working with loops.

This must be your own individual work. Do not look at anyone else's solution (or even part of it), and do not let anyone else look at yours (or even part of it). You should figure out the solutions by yourself; i.e., don't ask anyone how to solve the problem, and don't seek the answer from some other source. The only way to learn how to program is to go through the problem solving and debugging processes yourself. It is fine to ask questions about Python itself, however.

Part 1: Write a program to test your functions.

Create a function main() that is similar to the one in stringFuns.py to test the functions you will write in Part 2. Your function main() should include at least 3 test cases for each of your functions. Since the functions merely print things, and do not return values to be tested, you won't be able to use function "grade" to check your answers. Main should call the function directly, and you will need to inspect the results to check whether they are correct.

Part 2: Write the following functions.

Function Name Specification
caloriesBurned Given the number of calories burned per minute (a float), and ints indicating a starting number of minutes, an ending number of minutes and an interval of minutes, print a table of the number of calories burned after the starting minutes, after the starting number of minutes + interval minutes, etc., stopping when the next interval would be greater than the ending number of minutes. E.g. caloriesBurned(3.9,10,33,5) would print 10, 39.00; 15, 58.50; 20, 78.00; 25, 97.50; 30, 117.00. However, Your output should be formatted as a nice table with headers. Use your judgement about how to format the table. (Section 2.8 pp. 65-73 gives details about printing and formatting. Hint: the \t character may be useful.)'''
displayWedge Given a number of lines, numLines, and a character c, draw the following pattern, where the top-most line has numLines c's, and the bottom line has one c (in this example, numLines is 7 and c is *) (hint: reading Chapter 5 will help!). If the character c is not specified, then by default it should be *
*******
******
*****
****
***
**
*
displayLadder Given a number of lines, numLines, and a character c, draw the following pattern. In the example, numLines is 6 and c is #. If the character c is not specified, then by default it should be * Click here for the pattern.
multiplicationTable Given an int, dim, display a dim x dim multiplication table.

Submission

Put all your functions, including "main", in a file called assign2.py. Your program should call function main at the end. Submit that file via courseweb.

Grading

These are the aspects of your work that we will focus on in the grading: