Exam 1 Lab Project

Your lab assignment, worth 50 points, involves solving two problems.

Warning

Both parts should be on one file that must be submitted by midnight on Thursday, Oct 11. You will need to upload a copy of the lab file to your homework repository, in a folder named Exam1.

Part 1: Problem statement:

Mr. Brown owns 15 apartments that he rents with annual leases. The usual monthly rent for apartments numbered 1 through 9 is $700; the usual monthly rent for apartments numbered 10 through 15 is $850. The usual rent is due every month except July and December; in these months Mr. Brown gives his renters a 50% discount so they owe only half the usual amount. Design a program that will calculate the rent for one of Mr. Brown’s apartments for any given month.

What your program should do:

The program should ask the user for the apartment number, and the month. You can use numbers between 1 and 12 for the months, or strings as you see fit.

Your program should use a function to calculate the rent. The input data (apartment number and month) should be used to calculate the rent. The function should print the result on the screen.

Your program should handle multiple problems, so you need a loop. Here is a chunk of code you can use:

apartment_number = int(input("Enter apartment number (0 to quit): ")
if apartment_number > 0:
    # process rent code goes here
    apartment_number = input('Enter apartment number (0 to quit): "

Part 2: Problem statement

This part involves adding code that will generate output after part 1 completes (you entered a 0 for the apartment number.

In this part, you are to write a function named “triangle” that takes a single parameter named “width”. Your goal is to create an output that looks like this for a width of 5:

*
**
***
****
*****
****
***
**
*

Writing this part

You need to add code that asks the user for a width to use when printing the triangle. This is an ideal time to try the counted for loop:

for count in range(0,width):

You do not need to use this unless you want to. You can use the while-loop as well, and you will probably use more than one loop to get this done!