You are on page 1of 6

The University of the South Pacific

School of Computing, Information & Mathematical Sciences

IS104: Computing for Science and Technology

Assignment 3
Learning Outcome:
 Describe the fundamentals of computing and programming.
 Apply programming skills to applied science problems
Weight: 30%
Due Date: 12th June, 2020.

Part 1: Programming – Syracuse Sequence (20%)


1.1 Problem Statement

The Syracuse (also called the Collatz Hailstone) sequence is generated by starting with a
natural number and repeatedly applying the following function:
𝑥/2, 𝑖𝑓 𝑥 𝑖𝑠 𝑒𝑣𝑒𝑛
𝑠𝑦𝑟(𝑥) =
3𝑥 + 1, 𝑖𝑓 𝑥 𝑖𝑠 𝑜𝑑𝑑

For example the Syracuse sequence starting with number 5 is: 5,16,8,4,2,1. This is an open
question in mathematics whether this sequence will always go to 1 for every possible starting
value.

1.2 Problem to be Solved

You will find a data file on Moodle alongside your assignment specifications called “data.txt”.
This data file contains natural numbers, one on each line.

1. Your role as a programmer is to create a program that will read all this data from the file
and generate the Syracuse sequence for each of those numbers.
2. Additionally, you have to write every one of these Syracuse sequences into a file called
Syra.txt using your code.

Task 1: Write an algorithm to solve the problem mentioned above. Your algorithm must
have a file reading loop as well as the calculation for Syracuse. This should be written as
pseudocode and added as comments in your python file.

Task 2: Translate your algorithm into a Python program. The python


implementation must have try ... except block to catch the runtime errors to make the
program safe from any unwanted crashes.
1.2.2 Use of Functions in Assignment:
It is necessary that you implement this assignment using functions. To obtain the maximum
score you must demonstrate some ability to create and use functions of your own.
1.3 Important Note:
In your program you must write comments where necessary. Don’t write comments for obvious
code, but segments of code which seem complex. Also include your name, student id# and
tutorial group as comments at the top of your program code.
Partial Credit:
Even if your program does not work perfectly, you will receive partial credit for each part you get
to work. For example, if your program compiles but gives incorrect results, you can still receive
a mark provided that your code is well-written.

Part 2: Fundamentals of Programming (10%)

Most important basic elements for programming languages are:

 Programming Environment
 Data Types
 Variables
 Keywords
 Logical and Arithmetical Operators
 If else conditions
 Loops
 Numbers, Characters and Arrays
 Functions
 Input and Output Operations

In Part 1 of this assignment, you have used all of these fundamental parts of the program. Your
task now is to create a report on each of the aforementioned fundamentals and give examples
from you code where and why you have used them. You must also do a general discussion on
what is meant by each of the fundamentals.

Your report will need to have a cover page and a bibliography section for listing any and all
components that you have referenced in this assignment.

The body of the report will just be the 10 sub headings listed above and your discussion on
these programming fundamentals with direct reference to you code from part 1.

Part 3: Assignment Rules and Submission Instruction


3.1 Individual Assignment.
This is an individual assignment. You must not share your program nor your report with
anyone. You can discuss the assignments with your friends, however, if you share your code,
the it will be classed as plagiarism and you will be penalized.
3.2 Submit before the Deadline
You have to submit your work before the deadline mentioned above. Lab computers are scarce,
so the trick is to start EARLY. Also when you finish don’t hold on to your assignment till the last
moment. Submit as soon as you are satisfied with it.
3.2.1 Submitting late:
If you think that you will not be able to submit the assignment on time due to circumstances
which are beyond your control, then you will need to seek approval from the course coordinator
prior to the due date.
This means you have to ask for an extension, explaining the reasons, before the deadline, and
not after. A late submission will be penalized by 20% for each 24 hour period it is late. Where
possible, it is better to hand in your work early and get credit for partial work than handing in
late. A partial work may earn more points than a working assignment which is submitted late.
3.3 Submission
You will have to submit exactly two files on Moodle.
1. A program file for Part 1 (.py file)
2. A report for Part 2. (.pdf file or .docx file)
Note: Be sure you rename both these files using the templte; .
1. Asg_3_SXXXXXXXXX.py, where SXXXXXXXXX is your student id number
2. Asg_3_ SXXXXXXXXX.pdf or Asg_3_ SXXXXXXXXX.docx
Be sure that you submit the assignment only once you are totally satisfied. We will not accept
“corrected versions” submitted through other channels after the due date. However, you can
submit the assignment as many times as you like on Moodle before the due date!
3.4 Plagiarism
For this and other work in IS104, it is essential that you avoid plagiarism. Not only do you
expose yourself to possibly serious disciplinary consequences, but you will also cheat yourself
of a proper understanding of the concepts emphasized in the project. You will almost certainly
fail the short tests and/or the final which will test your understanding of the project. It is not
plagiarism to discuss the assignment with your friends and consider solutions to the problems
together. However, it is plagiarism for you to copy all or part of each other’s programs. If you
find somebody has stolen your assignment and produced it as their own, it will be considered
plagiarism. We are using automated tools to assist with the detection of plagiarism.
They will highlight any unusual code that is similar between students. All cases that are flagged
as potential plagiarism will be checked by hand. So do not leave your flash drives around. Be
careful with them. And make sure you log out of the lab machines when you are finished
working with them. Don’t copy part of someone solutions, and do not give somebody else an
electronic copy of your solution. If you give someone your program it is almost guaranteed that
part of it will end up in their program, no matter whether you ask them not to copy.
Any student posting code for this project on Moodle will be considered to be committing
plagiarism. Do not submit your code to any discussion group or mail it to anyone except the
lecturers or tutors.
Do not be concerned if Moodle tells you that a file cannot be checked by TurnItIn for
plagiarism. This will be your program file. We will check programs separately once
submitted.
3.5 Support
If you have a problem with the assignment, with python or IDLE the exercises, and questions in
this assignment, lecture notes, the book, please ask. First use the forum for your questions. This
will also help other students with the same questions. Then ask your tutor for help, or otherwise
the course coordinator.
If you have any problems with the assignment or the course, feel free to email, visit or call the
course coordinator. All contact information is on Moodle.
Program Marking Rubric

Exceptional Acceptable Amateur Unsatisfactory

Documentation The code is well Comments describe most There is visible attempt to There are no comments, or
documented. Comment components, variables and comment all components poor comment; out - dated,
(6 Marks) describes the main functions. Some comments and functions. However, irrelevant, or cryptic
components, variables, might be dated; most some comments might be
functions. Comments are comment may make sense outdated, or only relevant
used to describe the to someone unfamiliar to someone familiar with
structure. The comments are with code the code
up to date. The comments
are relevant, and make
sense to someone
unfamiliar with the code

(6 Marks) (4 Marks)
(2 Marks) (0 Marks)

Programming The code uses layout to The layout of the program The layout of the program The layout of the program is
Style convey the structure of the makes it possible to identify makes it possible to identify coincidental, and makes it
program clearly. Different the structure of the the structure of the difficult to identify the
(6.5 Marks) components are easily program. Names are program with some effort. structure of the program.
recognized. Name are by meaningful in the context Names make sense to a Names are cryptic. No
themselves meaningful if of the problem. The code person familiar with the discernible effort was made to
they refer to the specific adheres to general good problem. The code makes adhere to common coding
problem and generic if they coding practices, and the adheres to some good practices. The output
refer to part of the code that output is spelled practices, but ignores contains spelling mistakes,
is reusable. The code correctly with only others. Some minor spelling and does not make an effort
adheres to the given coding minor mistakes, or mistakes in to ensure proper formatting
guideline. All output is spelt glitches in layout layout
correctly with a proper
layout.
(4 Marks) (0 Marks)
(6.5 Marks) (2 Marks)

Semantics The program uses the The program uses most The program works most of The program has several
programming construct constructs correctly and as the times correctly given minor run time errors, like
(6.5 Marks) correctly and competently. intended, and is only some implicit assumptions use of uninitialized variables,
The program does avoid sometimes overly about its use. The program or one or more fatal run
programming short cuts, complicated. It may uses constructs differently time errors. It uses
and does not abuse syntax. contain from their intended use. programming constructs with
There are no superfluous a few minor semantic There may be a few run no regard for their semantics
statements or conditions, no errors, such as dead time errors that manifest or intended use
dead code, no unused code, themselves for unusual
variables, no uninitialized or unused variables, but input or for certain
variables, no potential nothing that would cause compilers
division by zero or other a run-time error
run-time error
(4 Marks) (2 Marks) (0 Marks)
(6.5 Marks)

Functional The program satisfies all The program satisfies the The program satisfies the The program does not
Correctness requirements and requirements almost core requirements. Some satisfy core requirements.
produces the correct completely, and produces requirements might not It is easy to find examples
(6 Marks) behavior for all possible legal the correct answer for be addressed. It produces where the program
input. It handles incorrect all obvious legal input. the correct output for computes the wrong result.
input and responds It handles all incorrect obvious legal input The program does fail for
adequately Input without fatal failures unexpected input

( 2 Marks) (0 Marks)
(6 Marks) (4 Marks)

You might also like