辅导案例-CSCA20

欢迎使用51辅导,51作业君孵化低价透明的学长辅导平台,服务保持优质,平均费用压低50%以上! 51fudao.top
CSCA20
Exercise 1
(Functions, types and If statements)


Deadline
Sunday October 6th at 11:59pm.

Your Task
In this exercise, you will be practicing the implementation of some simple functions. Within the
file e1.py, you will find the (unfinished) definitions and docstrings of four functions, which you
will be required to complete by writing code for their bodies. The areas where you are
supposed to write your code are clearly denoted with comments.
The docstring for each function describes what each function is supposed to do and/or return.
It is up to you to implement the functionality.

What you should also do
In the comments of e1.py, you will see that I have given suggestions for testing your functions.
While we will not be grading you on how well you test your functions, we will be grading you
on how well your functions work. And the best way for you to make sure your functions work
is to test them thoroughly.

In general, for any given function argument, you should follow the following guidelines:
● For arguments which are numbers, you should try (where applicable; not every
function requires the usage of all of these):
o A value of 0
o A positive value
o A negative value
o Integer values
o Non-integer values
● For arguments which are strings (where applicable; not every function requires the
usage of all of these):
○ The empty string (often forgotten)
○ A string with one character in it
○ A string with multiple characters in it
○ A string containing letters (a, b, c, etc.)
○ A string containing digits (0, 1, 2, etc.)

For functions which accept multiple arguments, you should generally try all combinations of
these for all arguments.

Attention to detail
Remember that Python cannot make any intelligent corrections for you. It will only do exactly
what you tell it to. Any typos or logical errors will make your code behave completely
differently from what you want it to! So, the best way to make sure you haven't made any of
these errors is to test! (See above)

Style
The adherence of your modified e1.py to the PEP8 style guide will count towards your grade.
After you've implemented and tested your code, run it through the online style-checker
provided in the Resources section of Quercus and then fix all of the style errors it will no
doubt find in your code.

It may seem tedious to write according to the PEP8 style guide when Python will understand
non-PEP8-compliant code just as well. But remember that when you're programming, you're
programming for humans as well. Writing code which follows style conventions will help
humans read it. And as you practice following these conventions, they will become habit and
you might eventually find yourself doing it by default.

Thus, the second last thing you should do before you submit is to run your code through the
PEP8 style checker. The last thing you should do is the sanity check (see below).

Sanity check
If nothing else, make sure your code runs without any syntax errors. In lecture, you've seen
how easy it is to forget a bracket and end up with invalid Python code. Even the best
programmers make these mistakes regularly. If the code you eventually submit has these
kinds of errors, you will get a 0 on your exercise grade, no matter how well you did everything
else! So the last thing you should do before you submit is a final sanity check to make sure
you can at least run your code without any errors!

What to hand in
Submit your completed e1.py on Quercus

欢迎咨询51作业君
51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: abby12468