Question 1 (30 points):
Purpose:
To practice planning, designing, implementing, and testing a
Python program.
Degree of Difficulty:
Moderate. Don’t leave this to the last minute. The basic
functionality of the various parts of this question are easy. There
are aspects of some parts that you won’t appreciate until you start
testing.
References:
You may wish to review the following chapters:
•Development Processes: PCS Chapter 5
•Procedural Abstraction: PCS Chapter 6.
•Testing: PCS Chapter 7.
In this question you will apply an informal design process to
the task of implementing a program at the level of Assignment 1.
The purpose is to follow the process thoughtfully and reflectively.
Please read the question description carefully before you
start!
What to Hand In:
Usually this appears last, but in this question, it’s first so
that you know what you have to hand in. As you can see, the code
you develop is a small part of this work.
•Your plan to complete this question:
a3q1_plan.txt
•Your design document:
a3q1_design.txt
•Your answers to the reection questions:
a3q1_reflections.txt
•Your Python program
a3q1.py
•NEW!
Your test script
a3q1_testing.py
You are allowed to use PDF, RTF, DOC les instead of TXT. Be sure
to include your name, NSID, student number, course number and
lecture section at the top of all documents.
Problem Specication:
The program you will write will be concerned with word-chains,
dened as follows.
A word-chain is a sequence of words where each sequential pair
of words differs by exactly one letter.
For example, the following is a valid word-chain, consisting of
exactly 3 words:
shop
stop
step
The words “shop” and “stop” differ by exactly one letter; the
words “stop” and “step” differ by exactly one letter. Word-chains
can be arbitrarily long.
However, the following is not a valid word-chain:
cold
coat
boat
It is not valid because the words “cold” and “coat” differ by
more than one letter.
Your program will determine whether a word-chain is valid by the
following criteria, in the following order:
1.The word chain has at least 2 words in it. If
there are fewer than 2 words in the word-chain, your program should
display the following text on the console:
Invalid:too short
2.Each word is a valid word.If an invalid word
(e.g., “sidx”) appears in the word-chain, your program should
display the following text on the console:
Invalid word: sidx
You only need to identify the rst invalid word in the
word-chain.
To determine whether a word is valid, you will be given a le
with 500 four-letter words, in alphabetical order, called four.txt.
These words are valid; if any word in a word-chain does not appear
in this file ,it is not valid.
3.No word in the word-chain appears more than
once. If a word appears more than one in the word-chain,
your program should display the following text on the console:
Invalid:repeated word:case
You only need to identify the rst repeated word in the
word-chain.
4.Each sequential pair of words differs by exactly one
letter.If two words in the word-chain differ by more than
a single letter, your program should display the following text on
the console:
Invalid step from bred -> arid
You only need to identify the first invalid step in the
word-chain.
5.If the word-chain is valid by the above
criteria,then your program should display the following
text on the console:
Valid!
Word-chain examples are provided in a ZIP file. Each example is
a file containing 4-letter words, one word per line. Your program
should ask for the name of a file, read the file, and check for
validity. For example,it might look like this:
Name of chain file to check? A3Q1_09.txt
Invalid step from fell -> call
The purpose of this question is to get you to deliberately spend
time planning, designing, implementing, and testing an application,
using the concepts from Chapters 4-7. You will be expected to
create a design
document, along the lines of A2Q3, then implement the design,
and test the implementation. To accomplish this, you should create
a plan, in which you schedule the different parts of your work (see
page 8).
-For this question you will do the following:
•You will start by creating a plan for your work. Your plan will
schedule time for the following development phases:
– Requirements.The specication is given above,
so this part of the plan includes reading the Specication section
carefully. You do not need to hand in anything for this part.
– Design.Your plan will indicate when you will
do the design phase (day, time, location), and how long you think
it will take (duration).
– Implementation.Indicate when you will work on
the implementation phase (day, time, location),using your design,
and how long you think it will take (duration).
– Testing and debugging.Indicate when you will
work on testing and debugging (day, time, location), and how long
you think it will take(duration).
– Final clean up for submission.Indicate when
you will work on clean-up (day, time, location), and how long you
think it will take (duration).
You must submit this plan for grading.
•You will design your program, producing a design document
outlining your implementation. You will submit this design for
grading.
•You will record the amount of time you actually spent on each
phase of the plan. You will submit this information for
grading.
Note:
If you do not engage with the planning and design, you are
avoiding the main learning objective. The application you are
developing is not important enough to spend time on, except to gain
some experience doing the planning and design.
Details about the Design
Your design document should describe your implementation in
terms of the functions you’ll need to complete the program. For
each function, you must specify:
•Pseudo-code or informal algorithm descriptions. The form of the
description is up to you.
•An informal description of the inputs and outputs for each
function.
•An informal description of any test cases you will need to
check your functions.
It’s important for you to keep in mind that the purpose of the
design is to help you, and you should not be overly worried about
the format of your design.
Details about the Implementation, Testing, and
Debugging Try to apply an incremental approach. For each
function in your design:
•Implement the function according to your design.
•Test your function.
•Debug as necessary.
Keep track of your time during these phases. You’ll want some
objective evidence for how long things actually take, compared to
what you estimated in your plan. This objective evidence will help
you prepare
more realistic plans in the future! How you actually complete
these phases is less important than being objective about your
progress.
Details about your submitted program
The program is the least important part of the assignment.
Make
it look presentable, by adding comments and doc-strings to your
functions.
Details about your reflection Your answers to
the reflection questions below are graded for relevance and
thoughtfulness of your answer. There are no right answers, and the
only way to lose these marks is to fail to reflect
meaningfully.
Reflection questions
1. How long did it take for you to create your plan?
2. Did you revise your design? In other words, did any part of
your implementation turn out to be significantly different from
your design? If so, briey explain the reason for the
difference(s).
3. Did any of the phases take significantly longer than you had
planned? If so, explain what happened,and suggest ways to avoid
this in the future.
Evaluation
•5 marks: Your plan allocated time to every phase of the
development process, and the times were plausible.
•5 marks: Your design gave complete and useful details in terms
of function descriptions, pseudo-code algorithms, and test
cases.
•5 marks: Your answers to the reflection questions were
thoughtful and relevant.
•5 marks: Your program is correct, and not terribly
inecient.
•5 marks: Your program is well-documented with helpful comments
for the reader.
•NEW!
5 marks: Your test script has test cases for every function, and
is plausibly thorough.
Question 1 (30 points): Purpose: To practice planning, designing, implementing, and testing a Python program. Degree of
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am