**Click once—type in course code—do not use return key** (2004)
COMP 1039
Problem Solving and
Programming
Programming
Assignment 1
UniSA STEM
The University of South Australia
March, 2021
2 of 33
Contents
Introduction
Assignment Overview
Graduate Qualities
Part I Specification
Practical Requirements (Part I)
Stages (Part I)
Part II Specification
Practical Requirements (Part II)
Stages (Part II)
Submission Details
Extensions and Late Submissions
Academic Misconduct
Marking Criteria
Sample Output – Part I
Sample Output – Part II
Useful Built-in Python Functions – you should read this! : )
3 of 33
INTRODUCTION
This document describes the first assignment for Problem Solving and Programming.
The assignment is intended to provide you with the opportunity to put into practice what you have learnt in the course
y applying your knowledge and skills to the implementation of a game called In-Between (three dice game) and a
simple number converter.
This assignment is an individual task that will require an individual submission. If you are an internal student,
you will be required to submit your work via learnonline before Tuesday 27 April (week 7), 9am. Internal students are
not required to demonstrate their work in person.
This document is a kind of specification of the required end product that will be generated by implementing the
assignment. Like many specifications, it is written in English and hence will contain some imperfectly specified parts.
Please make sure you seek clarification if you are not clear on any aspect of this assignment.
ASSIGNMENT OVERVIEW
There are two parts to this assignment:
Part I: In-Between (Three dice game)
You are required to write a Python program that allows a player to play a game of In-Between (three dice game).
The program will allow a player to play as many games of In-Between as they wish. Once the player chooses to stop
playing, the program will report the game statistics to the screen.
Part II: Number converter
You are required to write a Python program that performs decimal to binary conversion (and vice versa) on numbers
entered by the user. You are only required to deal with whole numbers. If you are interested, you may like to read the
following on binary numbers: http:
en.wikipedia.org/wiki/Binary_number.
"There are only 10 types of people in the world: those who understand binary, and those who don't."
http:
en.wikipedia.org/wiki/Mathematical_joke
Please ensure that you read sections titled ‘Part I Specification’ and ‘Part II Specification’ below for further
details.
http:
en.wikipedia.org/wiki/Binary_numbe
http:
en.wikipedia.org/wiki/Mathematical_joke
4 of 33
GRADUATE QUALITIES
By undertaking this assessment, you will progress in developing the qualities of a University of South Australia
graduate.
The Graduate qualities being assessed by this assignment are:
The ability to demonstrate and apply a body of knowledge (GQ1) gained from the lectures, workshops,
practicals and readings. This is demonstrated in your ability to apply problem solving and programming
theory to a practical situation.
The development of skills required for lifelong learning (GQ2), by searching for information and learning to use
and understand the resources provided (Python standard li
ary, lectures, workshops, practical exercises,
etc); in order to complete a programming exercise.
The ability to effectively problem solve (GQ3) using Python to complete the programming problem. Effective
problem solving is demonstrated by the ability to understand what is required, utilise the relevant information
from lectures, workshops and practical work, write Python code, and evaluate the effectiveness of the code by
testing it.
The ability to work autonomously (GQ4) in order to complete the task.
The use of communication skills (GQ6) by producing code that has been properly formatted; and writing
adequate, concise and clear comments.
The application of international standards (GQ7) by making sure your solution conforms to the standards
presented in the Python Style Guide slides (available on the course website).
5 of 33
PART I SPECIFICATION – IN-BETWEEN
You are required to write a Python program called yourEmailId_inbetween.py that allows a player to play a
game of In-Between (three dice game). The program will allow a player to play as many games of In-Between as
they wish.
In-Between Rules (three dice game)
In-Between is a simple card game where a player is dealt two cards face-up. Before a third card is dealt, the player
ets whether the third card will numerically fall in between the first two cards dealt. If the player wins (that is, the third
card numerically falls in between the first two cards), the player collects the bet amount, if the player loses (that is, the
third card falls outside of the first two cards), the player loses the bet amount.
http:
en.wikipedia.org/wiki/Acey_Deucey_(card_game)
This card game translates well into a dice game. Instead of a deck of 52 cards, you will use three 12 sided dice in
order to play the game.
Although there are many variations of the rules and game play of In-Between, we will be adhering to the
following rules and game play for the assignment.
You are to simulate three 12 sided dice in order to play the game of In-Between with dice (the face value on each die
is 1 – 12 inclusive). Two dice are rolled, the player then bets whether the third die rolled will numerically fall in
etween the first two dice rolled. If the player wins (that is, the third die rolled falls numerically in between the first two
dice rolled), the player collects the bet amount, if the player loses (that is, the third die rolled falls numerically outside
the first two dice rolled), the player loses the bet amount. You will be betting with chips (not the edible kind) – you will
start with 100 chips.
Game play and rules:
To begin, two 12-sided dice are rolled (the face value on the dice are 1 – 12 inclusive).
Before any more die are rolled, the player then bets from nothing (zero) to however many chips they cu
ently
have (starting chip amount is 100) whether or not the third die rolled will numerically fall in between the first
two rolled.
If the third die rolled numerically falls in between the first two rolled, the player wins and the player’s bank
alance will be increased by the amount of chips bet.
If the third die rolled numerically falls outside of the first two rolled, the player loses and the player’s bank
alance will be decreased by the amount of chips bet.
If the third die rolled is the same as one of the first two rolled, (for example: if the player has a 3 and 8, and
the third die rolled is another 3), the player has ‘hit the post’ and loses the bet amount from their cu
ent chip
alance.
If the two dice rolled at the start of the game have the same face value, (for example: two 5s are rolled), no
further game play is required for that round and the player may choose whether to play again or not. This
does not change the player’s chip balance in any way.
http:
en.wikipedia.org/wiki/Acey_Deucey_(card_game)
6 of 33
PRACTICAL REQUIREMENTS (PART I)
It is recommended that you develop this part of the assignment in the suggested stages.
It is expected that your solution will include the use of:
Your solution in a file called yourEmailId_inbetween.py.
Appropriate and well constructed while and/or for loops (as necessary).
Appropriate if, if-else, if-elif-else statements (as necessary).
The use of random.randint(1,12) function in order to simulate the roll of a twelve sided die.
The following three functions (refer to stage 11 for the description):
o display_details()
o display_dice(die1, die2, die3)
o get_play_again(display_str)
Output that strictly adheres to the assignment specifications. If you are not sure about these details, you
should check with the ‘Sample Output – Part I’ provided at the end of this document or post a message to the
discussion forum for clarification.
Good programming practice:
o Consistent commenting, layout and indentation. You are to provide comments to describe: your
details, program description, all variable definitions, all function definitions, and every significant
section of code.
o Meaningful variable names (no single letter identifier names).
Your solutions MUST NOT use:
eak, or continue statements in your solution. Do not use the quit() or exit() functions or the
eak
or return statements (or any other techniques) as a way to
eak out of loops. Doing so will result in a
significant mark deduction.
PLEASE NOTE: You are reminded that you should ensure that all input and output conform to the
specifications listed here; if you are not sure about these details you should check with the sample output
provided at the end of this document or post a message to the discussion forum in order to seek clarification.
Please ensure that you use Python 3.9.2 or a later version (i.e. the latest version) in order to complete your
assignments. Your programs MUST run using Python XXXXXXXXXXor latest version).
7 of 33
STAGES (PART I)
It is recommended that you develop this part of the assignment in the suggested stages. Many problems in later
stages are due to e
ors in early stages. Make sure you have finished and thoroughly tested each stage before
continuing.
The following stages of development are recommended:
Stage 1
To begin, roll two 12-sided dice (the face value on the die are 1 – 12 inclusive). Use the random.randint()
function to create a simulation of rolling the player’s hand. Display the value of die 1 and die 2 as seen below.
Sample output:
Die 1: 3 Die 2: 7
Make sure the program runs co
ectly. Once you have that working, back up your program.