CPSC 231: Mini-Assignment 3A
Due Monday Oct 31 at 4 PM
New Concepts to be applied for the assignment
- Defining and calling a function that takes a single argument
Description:
Write a program that will produce a secret 'secure' composite code. The first
part of
the code will consist of a randomly generate number from 1 - 100 (you can use
the capabilities of randrange()). The second part
of the code will be a string entered by the user. These two parts will be
connected together in the form of a string.
Implementation:
Unless otherwise specified your program instructions do not have to belong to
the body of a particular function e.g. like the first two
print() statements below
print('1') # Outside
print('2') # Outside
def fun():
print('3')
# Inside function body
You need to define a function called 'completeCode()'. The random generation of the number and the call to
function 'completeCode()' do not have to be in the
body of a function. The rest of the program statements must be defined within
the body of the function completeCode().
- This function takes the randomly generated number as an argument.
- It will prompt the user for the character part of the 'code'.
- It will 'complete' the code by
connecting the two parts and displaying the result via a
print().
Grading:
- (Outside of a function): Randomly
generating a number from 1 - 100: Worth 0.5 grade points
- (Outside of a function): Call to the
completeCode(<numerical argument>)
function (the function must be properly defined, even with an empty body, in
order to get credit for this part: Worth 1.0 grade points
- (Part of a function):
completeCode(<numerical argument>)
header has been properly defined for the body of the function (takes a
numerical argument, correct name):
Worth 1.0 grade points
- (Part of a function): Prompts for and gets
as input the character part of the secret code: Worth 0.5 grade points
- (Part of a function): Connects the two
parts of the code yielding a string in the correct order (random number
followed by the user entered string): Worth 0.5 grade
points
- (Part of a function): Displays the correct
code: Worth 0.5 grade points
Marking spreadsheet
Points to keep in mind:
- Due time: All assignments are due at 4 PM on the
due dates
listed on the course web page. Late assignments or components of
assignments will not be accepted for marking without approval for an
extension beforehand. What you have submitted in D2L as of the due date is
what will be marked.
- Extensions may be granted for reasonable cases by the course
instructor with the receipt of the appropriate documentation (e.g., a
doctor's note). Typical examples of reasonable cases for an extension
include: illness or a death in the family. Cases where extensions will not
be granted include situations that are typical of student life: having
multiple due dates, work commitments etc. Tutorial instructors (TA's) will
not be able to provide extension on their own and must receive permission
from the course instructor first. (Note: Forgetting to hand your assignment
or a component of your assignment in does not constitute a sufficient reason
for handing your assignment late).
- Method of submission: You are to submit your assignment using D2L
[help
link]. Make sure that you [check
the contents of your submitted files] (e.g., is the file okay or was it
corrupted, is it the correct version etc.). It's your responsibility to do
this! (Make sure that your submit your assignment with enough time before it
comes due for you to do a check).
- Identifying information: All assignments should include contact
information (full name and student ID number) at the very top of your
program in the class where the 'main()'
function/method resides.
- Collaboration: Assignments must reflect individual work,
group work is not allowed in this class nor can you copy the work of
others. For more detailed information as to what constitutes academic
misconduct (i.e., cheating) for this course please read the following [link].
- Execution: programs must run on the computer science network
running Python 3.x. If
you write you code in the lab and work remotely using a remote login program
such as Putty or SSH. If you choose to install Python on your own computer
then it is your responsibility to ensure that your program will run properly
here. It's not recommended that you use an IDE for writing your programs but
if you use one then make sure that you submit your program in the form of
text ".py" file or files
- Use of pre-created Python libraries: unless otherwise told you
are to write the code yourself and not use any pre-created functions from
the Python libraries. For this assignment acceptable functions include:
print(), input()
and almost certainly str() and the random
number generator in the Python 'random'
module/library.
Marking
- Assignments will be marked by the tutorial instructor.
- You can contact him/her for the grade and/or the completed marking sheet.
- If you still have questions or issues after contacting your TA then feel free to
contact your course instructor.
D2L configuration for this course
- You can (and really should) submit work as many times as you wish before
the due date
- Only your latest submission (what you submitted previously will be
overwritten by your latest submission)
- You can only submit one file per assignment. To submit multiple files
then can use a program such as zip to compress the multiple files to contain
all the documents in one document: