首页 > > 详细

辅导python程序、讲解program编程、Python设计程序调试调试Matlab程序|解析SPSS

Assignment 1
Variables, Branching, Functions, Basic I/O, Algorithms, Testing
Due: Friday, September 29, 2021, 11:59PM pm (submit to cuLearn)
Submit a single zip file called A1.zip.
The assignment has 40 marks.
Notes: It is essential that you use the built-in, default, archiving program to create this zip file. If
we cannot easily open your zip file and extract the python files from them we cannot grade your
assignment. Other file formats, such as rar, 7zip, etc, will not be accepted.
Windows: Highlight (select with ctrl-click) all of your files for submission. Right-click and select
“Send to” and then “Compressed (zipped) folder”. Change the name of the new folder “A1.zip”.
MacOS: Highlight (select with shift-click) all of your files for submission in Finder. Right-click on
one of the files and select “compress N items…” where N is the number of files you have
selected. Rename the “Archive.zip” file “A1.zip”.
Linux: use the zip program.
After submitting your A1.zip file to cuLearn, be sure that you download it and
then unzip it to be certain that what you have submitted is what you wanted to
submit. This also checks that your zip file is not corrupted and can be unzipped.
Please note that reasons similar in nature to “I submitted the wrong files” or “I didn’t know the
zip file was corrupt” will not be accepted as an excuse after the due date.
Submit early and often. cuLearn will save your latest submission. I would highly suggest that
you submit as soon as you have one question done and keep re-submitting each time you add
another problem (or partial problem).
2
Late Policy
You have TWO 24-hour and ONE 12-hour late passes to use for assignments during the
semester, You can use one pass on an assignment or two (but you cannot use all three on a
single assignment).
You do not have to ask to use your passes. They will be used automatically. If you submit the
first assignment 3 hours late, your 12-hour pass will be used. You cannot later decide to use it
for another assignment.
Please note that cuLearn only keeps your LAST submission. If you submit on-time and then
submit the exact same files after the due date, it will be treated as being submitted after the due
date and either a late pass will automatically be used or the assignment will ultimately receive a
grade of zero (if all late passes are already used). Your assignment will still be graded and a
mark will appear in cuLearn. At the end of the semester when I am computing final grades, I will
adjust any late assignments that were submitted after all passes were used.
3
Q1: Turtles and Cows [20 marks]
Draw a cow,
Design your cow on paper. Using several basic shapes, like rectangles, squares, circles and
lines, design what your cow will look like (see the required elements needed below). Include
some coordinates (x and y locations) of where the shapes will be located. These do not have to
be exact but a good estimate. When mapping out your drawing, keep in mind that the shapes
will have colours and if two shapes overlap, the last one drawn will be on top of the other.
(Imagine cutting out small shapes of coloured paper and then placing them down to make your
cow.) You will take a picture (or scan) your design and submit this in a file called cow.pdf. If you
take a picture, simply embed it into an MS Word document and then export as PDF.
Now that you have your design, use the turtle graphics in Python to draw it. Add your turtle
commands to the provided cow.py file. Do not delete the lines of code already in the file. Just
add your code in the middle.
Requirements: Your picture must
● Look, more or less, like a cow (less is OK… abstract is OK...)
● Have at least FIVE coloured shapes (use begin_fill() and end_fill() for this)
● Use at least THREE different colours
● Be your own work
● Be a reasonable size (the TAs must be able to clearly see the different components, and
it should not be bigger than a typical sized laptop screen)
You can do this with a very small set of turtle commands such as
● forward(), left(), right()
● penup(), pendown(), pencolor(), pensize()
● begin_fill(), end_fill(), fillcolor()
Other commands that might make your life easier will be
● setheading(), goto(), setx(), sety()
● heading(), position()
You are NOT required to use anything more advanced than this. You are free to do so but it is
not required.
Note: You are NOT being graded on your artistic ability (or lack thereof). The question is really
asking you break down the problem into a sequence of individual steps to accomplish the goal.
4
Q2: Personal Unit Converter [20 marks]
You will create an interactive program which will act as your own personal unit converter. Your
program will do the following things:
1. When the program starts it should ask for the user’s name and then present a welcome
message (using the user’s name!)
2. It will then present the user with a list of possible conversions it can perform and ask for
the user to choose an option.
3. The user then makes a selection and the program will ask for a number to convert.
4. The program will then make the conversion and print it out.
5. The program will then present a closing message (again using the user’s name)
Your program will need to be able to perform at least 5 different conversions. In your code you
will write a function for each of your converters. Based on the user’s input you will call the
appropriate function. You are free to choose whatever conversions you would like but you must
include a “percent to letter grade” converter in your program. Use the following (simplified)
ranges for this conversion:
Grade Range Letter Grade
[80, 100] A
[70, 80) B
[60, 70) C
[50, 60) D
[0, 50) F
A note on this range notation: Depending on the type of bracket used when describing a range, the range will either
be inclusive or exclusive at that end. An inclusive end is represented using a square bracket and means that this
number is included in the range. An exclusive end is represented using a round bracket and means that everything
up to but not including this number is included in the range. For example, the A range is from 80% - 100%,
including both 80% and 100%. On the other hand, the C range is from 60% up to but not including 70% (ie. any
number in the sixties).
5
Here is a few examples of what running your program could look like (user input is highlighted to
help illustrate the example):
Please enter your name: cat
Hello Cat, welcome to your personal unit converter.
Please choose which conversion you would like to perform:
1 - convert cm to inches
2 - convert percent to letter grade
3 - convert cups to ml
4 - convert grams to ounces
5 - convert fahrenheit to celsius
Choice: 1
Value in cm to convert: 10
10 cm = 3.937007874015748 inches
Goodbye Cat.
---------------------------------------------------------
Please enter your name: dog
Hello Dog, welcome to your personal unit converter.
Please choose which conversion you would like to perform:
1 - convert cm to inches
2 - convert percent to letter grade
3 - convert cups to ml
4 - convert grams to ounces
5 - convert fahrenheit to celsius
Choice : 2
Percent to convert to letter grade: 67.1
67.1% = C
Goodbye Dog.
Submit your code in a file called convert.py.
Recap [A1.zip]
Submit a single zip file called A1.zip. Your zip file should the following THREE files:
● cow.py (this is your grade calculator program)
● cow.pdf (this is your plan for drawing your cow)
● convert.py (this is your unit conversion program)

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!