The goal of this assignment is to create a program that responds to the user's input automatically, using math.
This assignment is to be done individually. You can talk to other people in the class, me (Jadrian), the prefect (Katja), and lab assistants for ideas and to gain assistance. You can ask questions on Piazza. You and your classmates can also help each other debug programs, if you wish. The code that you write should be your own, however, and you shouldn't share your code with others (whether as an emailed file, printed or handwritten sheet, or anything else). See the course syllabus for more details or just ask me if I can clarify.
As before, it will be easiest to work in the CS labs. Working on other machines is not officially supported by this class, and your program will be run for grading on a configuration equivalent to a CS lab machine. So make sure it works in the lab.
Put your name in a comment at the top of each file you submit.
Many aspects of backgrounds and landscapes that you see in today's movies are computer enhanced. Perhaps the weather was wrong on the day the film was shot, or maybe the director had a change of mind involving the mood. For this assignment, you will create an image that can be changed and adjusted by the user.
Create a directory named landscape1 to store your work, then copy into it the graphics.py library that we used last time. Write Python code to make a canvas of size 500 pixels wide and 700 pixels high, then draw a simple landscape. Your landscape doesn't have to be particularly fancy. Set the background to blue to represent a sky, then draw a couple of rough hills or buildings using ovals or rectangles. Make sure you have a nice big sky.
Draw a small white cloud at the top left corner off your canvas. Your cloud can be as simple as a cloud-sized oval, but feel free to use multiple overlapping ovals or other techniques to make your cloud as attractive as you like.
The goal of this part of the assignment is to place the cloud in different places in the sky, depending on where the user of your program wants it.
Specifically, your program should ask your user for a wind speed (in miles per hour), and the number of hours that have passed since the cloud first appeared in the top left of the window. Your program should then draw the cloud in its correct location. Assume that the image is 20 miles across, and that the wind is blowing directly to the right.
Here is a sample of what the interaction between your program and your user should look like. The user's responses are in red, with a dotted underline, so that you can tell what the user has typed. (In reality, though, this should appear in the same color as all the other text in your terminal window.)
Automatic Landscape Builder What is the windspeed in miles per hour? 3.5 How many hours have passed? 2.5 Here is your picture!
The program would then show the user a picture, with the cloud in the correct place, according to the user's input.
You will need to do some arithmetic to determine precisely where the cloud should go:
num1 = 3.2 num2 = round(num1)
Here are some things you can do to test your code:
Finally, begin thinking about good style for your programs. You should make them as readable as possible for someone else trying to understand them. At a minimum, you should use comments at the top of your program indicating your name(s), and use comments above consecutive portions of Python code explaining what they do.
Good luck, and have fun! Remember that lab assistants are available in the evenings in CMC 306 to help out if you need it, and you can attend prefect sessions as well.
When you are finished, submit your work through Moodle. You do not need to include graphics.py or any files ending with .pyc. If you have only one file to submit, turn that in; otherwise, create a zip file called hw4.zip and submit that.
The following command creates a zip file called hw4.zip containing the files landscape.py and etc.py:
zip hw4.zip landscape.py etc.py