ECS 102 Baruch
Fall 2018
HW 6
Due: Thursday, Oct. 18, 11:59 pm
For this assignment you will be writing 3 programs in files, each with a main.
- Start each program with a comment like this:
# Official Name: Amanda Kitredge
# Nickname: Mandy
# email: ajkitred@syr.edu
# Assignment: Assignment 3, problem 1.
# Date: September 13, 2018
# a brief description of the problem.
Replace the italicised fields with appropriate information for you and for this assignment.
- In the “Official Name” field write your name as it appears on University documents.
- “Nickname” is the name you would like to be called by the course staff. If you don’t use a nickname you can leave this line out.
- In addition, each program should have comments describing the main sections of the program. They should be specific to the problem you are solving. Under each of these comments should be a chunk of code implementing the comment.
- Good readability:
- Use meaningful names for all variables.
- Use blank lines to delineate small portions of code that work together to accomplish a task.
- Test you program. Run each program with data as specified with that program.
output.docx (or pdf) for copies of output.
- Garden.py
For this program you will write a program to draw a garden.
First, write a function
setUpWindow()
It should create a WinGraph 600×600, and set the coordinate system to go from 0 to 10 in both directions. It should return the GraphWin.
Write a function
drawFlower(win, color, x, y)
It draws a flower – a green stem and a few circular or oval petals, with the base of the stem at x,y. You pick how big you want the flower. The color is for the color of the petals. win is the GraphWin
Main will use setUpWindow to set up the window.
Your garden should have a green background and then draw 5 flowers. You choose where.
Run the program. Paste the screenshot in output.docx (or .pdf)
- Receipt.py
You are going to write a program to produce a receipt for a school supply company.
Some of the items are taxable and some are not.
Teachers get a 10% discount off the final bill.
Write the following functions.
welcome()
Writes a welcoming statement. Asks the user how many items they are buying. Returns the number of items.
process(outfile, numItems)
proceeds through a loop, once for each item bought. Asks for the item, the price (a float), and the tax status “T” or “N” for taxable or not taxable. Prints the item, its price, and its tax status to the output file outfile.
Computes a running total for the items and a total for the tax. Use 5% tax rate for taxable items.
Prints the pre discount total and tax to the file.
Invokes another function:
discount (grandtotal)
Asks for the age of the buyer. If they are under 17, they get a 15% discount.
Asks if they are a teacher. If they answer “yes” they get a 10% discount.
Returns the adjusted total.
process then prints the final total to the output file.
Main, before processing a customer, asks for their name, and uses their name as the name of the file for the receipt. (Eg. baruchReceipt.txt). Main should open the file. This is the output file. There is no input file.
Main then invokes a function to process the receipt, passing the receipt file as an argument. After processing the the receipt, main asks for payment, and computes the change.
The amount of payment and the change are added to the receipt in the file as well as printed to the screen, and the output file should be closed.
Put the screen output in output.docx (or .pdf) and save the receipt file to upload, too, as a separate file.
- Circles.py
For this program you will call the function setUpWindow from part A.
You will then open a file, centers.txt, that has the coordinates of the centers of points, one pair on each line, and reads the file into a list inList. Main can use the length of the list to know how many points there are.
Write a function drawCircle(i, inList, win, color) that
reads the ith item in inList, and uses that data to draw a circle at that location, in the WinGraph win, with color color.
Put a screenshot of the window in output.docx (or .pdf)
______________________________________________________________
Upload:
Garden.py
Receipt.py
Circles.py
output.docx (or pdf)
receipt output file