Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
Assignment 1
Worth 13marks and due Week 7 Monday @ 10am
1. General Matters
1.1 Aim
The purpose of this assignment is to:
? develop your problem-solving skills.
? design and implement the solution to a problem in the form of a medium sized Python program.
? practice the use of arithmetic computations, tests, repetitions, lists, and strings.
? use procedural programming.
1.2 Marking
This assignment is worth 13 marks distributed approximately as follows:
1.50 marks for "I don't get what you want, sorry mate!"
3.50 marks for "Hey, ask me something that's not impossible to do!"
2.25 marks for "Please convert ***"
2.50 marks for "Please convert *** using ***"
3.25 marks for "Please convert *** minimally"
----------------------------------------------------------------------
13.00 marks total
Your program will be tested against several inputs. For each test, the automarking script will let your
program run for 30 seconds. The outputs of your program should be exactly as indicated.
2
1.3 Due Date and Submission
Your program will be stored in a file named roman_arabic.py. The assignment can be submitted
more than once. The last version just before the due date and time will be marked (unless you submit late
in which case the last late version will be marked).
Assignment 1 is due Week 7 Monday 25 March 2024 @ 10:00am (Sydney time)
Note that late submission with 5% penalty per day is allowed up to 5 days from the due date, that is, any
late submission after Week 7 Saturday 30 March 2024 @ 10:00am will be discarded.
Make sure not to change the filename roman_arabic.py while submitting by clicking on [Mark]
button in Ed. It is your responsibility to check that your submission did go through properly using
Submissions link in Ed otherwise your mark will be zero for Assignment 1.
1.4 Reminder on Plagiarism Policy
You are permitted, indeed encouraged, to discuss ways to solve the assignment with other people. Such
discussions must be in terms of algorithms, not code. But you must implement the solution on your own.
Submissions are scanned for similarities that occur when students copy and modify other people’s work or
work very closely together on a single implementation. Severe penalties apply.
2. Description
You will design and implement a program that prompts the user for an input with:
How can I help you?
User input should be one of three possible kinds:
Please convert ***
Please convert *** using ***
Please convert *** minimally
If the user input is not of this form, with any occurrence of *** an arbitrary nonempty sequence
of non-space symbols, then the program should print out:
I don't get what you want, sorry mate!
and stop.
3
2.1 First Kind of Input
In case the user inputs Please convert ***, then *** should be either a strictly positive
integer (whose representation should not start with 0) that can be converted to a Roman number
(hence be at most equal to 3999), or a valid Roman number; otherwise, the program should
print out:
Hey, ask me something that's not impossible to do!
and stop.
If the input is as expected, then the program should perform the conversion, from Arabic to
Roman or from Roman to Arabic, and print out the result in the form:
Sure! It is ***
2.2 Second Kind of Input
In case the user inputs Please convert *** using ***, then the first *** should be
a strictly positive integer (whose representation should not start with 0) or a sequence of
(lowercase or uppercase) letters and the second *** should be a sequence of distinct
(lowercase or uppercase) letters.
Moreover:
? the second *** is intended to represent a sequence of so-called generalised
Roman symbols. The classical Roman symbols corresponding to the sequence
MDCLXVI, whose rightmost element is meant to represent 1, the second rightmost
element 5, the third rightmost element 10, etc.
? if it is not an integer, the first *** is intended to represent a so-called generalised
Roman number, that is, a sequence of generalised Roman symbols that can be decoded
using the provided sequence of generalised Roman symbols similarly to the way Roman
numbers are represented.
If that is not the case, or if it is not possible to convert the first *** from Arabic to generalised
Roman or from generalised Roman to Arabic, then the program should print out:
Hey, ask me something that's not impossible to do!
and stop.
4
If the input is as expected and the conversion can be performed, then the program should indeed perform
the conversion, from Arabic to generalised Roman or from generalised Roman to Arabic, and print out the
result in the form:
Sure! It is ***
2.3 Third Kind of Input
In case the user inputs Please convert *** minimally, then *** should be a sequence
of (lowercase or uppercase) letters. The program will try and view *** as a generalised Roman
number with respect to some sequence of generalised Roman symbols. If that is not possible,
then the program should print out:
Hey, ask me something that's not impossible to do!
and stop.
Otherwise, the program should find the smallest integer that could be converted from ***,
viewed as some generalised Roman number, to Arabic, and output a message of the form
Sure! It is *** using ***
5
3. Sample Outputs (or Test Cases)
Here are a few tests together with the expected outputs. The outputs of your program should be exactly
as shown:
$ python3 roman_arabic.py
How can I help you? Please do my assignment...
I don't get what you want, sorry mate!
$ python3 roman_arabic.py
How can I help you? please convert 35
I don't get what you want, sorry mate!
$ python3 roman_arabic.py
How can I help you? Please convert 035
Hey, ask me something that's not impossible to do!
$ python3 roman_arabic.py
How can I help you? Please convert 4000
Hey, ask me something that's not impossible to do!
$ python3 roman_arabic.py
How can I help you? Please convert IIII
Hey, ask me something that's not impossible to do!