Skip to main content
留学咨询

新南威尔士大学COMP9021Assignment1课业解析

By May 15, 2020No Comments

新南威尔士大学COMP9021Assignment1课业解析题意:使用Python解决计算,数据结构和字符串的问题。解析:三个问题都涉及字符串处理的问题,将对应的字符转换为整数。   对于本程序,用户应该有三种输入,除了以外的输入程序应该进行提示,这三种输入对应的输出为:
1.Please convert ***:***代表罗马数字或整数,程序应该将罗马数字转换为正整数[0,3999]然后也能将整数转换为罗马数字,之后停止。
2.Please convert *** using ***,第一个***代表原本的罗马数字序列,第二个***表示指定的罗马数字序列表,该程序目的是将罗马序列用指定的序列进行转换成整数,从右到左按照(1,5,10,50,100,500,1000)的排序。如果程序不能进行转化,则进行一些输出。
3.Please convert *** minimally,将***代表的罗马数字,程序先查看这个罗马数字能否使用一般性的序列表(MDCLXVI)或其他序列表进行转换,如果能则将其转换为一个尽量小的正整数,并且输出这个序列表。 涉及知识点:Python,字符串更多可加微信讨论微信号:Ssss_970521pdf
Assignment 1COMP9021, Term 3, 20191. General matters1.1. Aim. The purpose of the assignment is to:• develop your problem solving skills;• design and implement the solution to a program in the form of a medium sized Python program;• practice the use of arithmetic computations, tests, repetitions, lists, and strings.1.2. Submission. Your program will be stored in a file named roman_arabic.py. After you have developedand tested your program, upload it using WebCMS. Assignments can be submitted more than once; the lastversion is marked. Your assignment is due by Sunday 27 October 2019, 22:00 (Week 6).1.3. Assessment. The assignment is worth 10 marks. It is going to be tested against a number of inputs. Foreach test, the automarking script will let your program run for 30 seconds.Late assignments will be penalised: the mark for a late submission will be the minimum of the awarded markand 10 minus the number of full and partial days that have elapsed from the due date.The outputs of your programs should be exactly as indicated.1.4. Reminder on plagiarism policy. You are permitted, indeed encouraged, to discuss ways to solve theassignment with other people. Such discussions must be in terms of algorithms, not code. But you mustimplement the solution on your own. Submissions are routinely scanned for similarities that occur when studentscopy and modify other people’s work, or work very closely together on a single implementation. Severe penaltiesapply.2. DescriptionYou 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 *** minimallyIf user input is not of this form, with any occurrence of *** an arbitrary nonempty sequence of nonspacesymbols, then the program should print outI don’t get what you want, sorry mate!and stop.2.1. First kind of input. In case the user inputs Please convert ***, then *** should be either a strictlypositive integer (whose representation should not start with 0) that can be converted to a Roman number (hencebe at most equal to 3999), or a valid Roman number; otherwise, the program should print outHey, 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 Romanor from Roman to Arabic, and print out the result in the formSure! It is ***122.2. Second kind of input. In case the user inputs Please convert *** using ***, then the frst ***should be a strictly positive integer (whose representation should not start with 0) or a sequence of (lowercaseor 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 classicalRoman symbols corresponding to the sequence MDCLXVI, whose rightmost element is meant to represent1, the second rightmost element, 5, the third rightmost element, 10, etc.;• if it is not an integer, the frst *** 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 ofgeneralised Roman symbols similarly to the way Roman numbers are represented.If that is not the case, of if it is not possible to convert the frst *** from Arabic to generalised Roman or fromgeneralised Roman to Arabic, then the program should print outHey, ask me something that’s not impossible to do!and stop. If the input is as expected and the conversion can be performed, then the program should indeedperform the conversion, from Arabic to generalised Roman or from generalised Roman to Arabic, and print outthe result in the formSure! It is ***2.3. Third kind of input. In case the user inputs Please convert *** minimally, then *** should be asequence of (lowercase or uppercase) letters. The program will try and view *** as a generalised Roman numberwith respect to some sequence of generalised Roman symbols. If that is not possible, then the program shouldprint outHey, ask me something that’s not impossible to do!and stop. Otherwise, the program should fnd the smallest integer that could be converted from ***, viewedas some generalised Roman number, to Arabic, and output a message of the formSure! It is *** using ***2.4. Sample outputs. Here are a few tests together with the expected outputs. The outputs of your programshould be exactly as shown.$ python3 roman_arabic.pyHow can I help you? Please do my assignment…I don’t get what you want, sorry mate!$ python3 roman_arabic.pyHow can I help you? please convert 35I don’t get what you want, sorry mate!$ python3 roman_arabic.pyHow can I help you? Please convert 035Hey, ask me something that’s not impossible to do!$ python3 roman_arabic.pyHow can I help you? Please convert 4000Hey, ask me something that’s not impossible to do!$ python3 roman_arabic.pyHow can I help you? Please convert IIIIHey, ask me something that’s not impossible to do!$ python3 roman_arabic.pyHow can I help you? Please convert IXIHey, ask me something that’s not impossible to do!$ python3 roman_arabic.py3How can I help you? Please convert 35Sure! It is XXXV$ python3 roman_arabic.pyHow can I help you? Please convert 1982Sure! It is MCMLXXXII$ python3 roman_arabic.pyHow can I help you? Please convert 3007Sure! It is MMMVII$ python3 roman_arabic.pyHow can I help you? Please convert MCMLXXXIISure! It is 1982$ python3 roman_arabic.pyHow can I help you? Please convert MMMVIISure! It is 3007$ python3 roman_arabic.pyHow can I help you? Please convert 123 by using ABCI don’t get what you want, sorry mate!$ python3 roman_arabic.pyHow can I help you? Please convert 123 ussing ABCI don’t get what you want, sorry mate!$ python3 roman_arabic.pyHow can I help you? Please convert XXXVI using VIHey, ask me something that’s not impossible to do!$ python3 roman_arabic.pyHow can I help you? Please convert XXXVI using IVXHey, ask me something that’s not impossible to do!$ python3 roman_arabic.pyHow can I help you? Please convert XXXVI using XWVIHey, ask me something that’s not impossible to do!$ python3 roman_arabic.pyHow can I help you? Please convert I using IIHey, ask me something that’s not impossible to do!$ python3 roman_arabic.pyHow can I help you? Please convert _ using _Hey, ask me something that’s not impossible to do!$ python3 roman_arabic.pyHow can I help you? Please convert XXXVI using XVISure! It is 36$ python3 roman_arabic.pyHow can I help you? Please convert XXXVI using XABVISure! It is 306$ python3 roman_arabic.pyHow can I help you? Please convert EeDEBBBaA using fFeEdDcCbBaASure! It is 49036$ python3 roman_arabic.pyHow can I help you? Please convert 49036 using fFeEdDcCbBaASure! It is EeDEBBBaA$ python3 roman_arabic.pyHow can I help you? Please convert 899999999999 using AaBbCcDdEeFfGgHhIiJjKkLlSure! It is Aaaabacbdcedfegfhgihjikjlk$ python3 roman_arabic.pyHow can I help you? Please convert ABCDEFGHIJKLMNOPQRST using AbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTSure! It is 11111111111111111111$ python3 roman_arabic.py4How can I help you? Please convert 1900604 using LAQMPVXYZIRSGNSure! It is AMAZING$ python3 roman_arabic.pyHow can I help you? Please convert ABCD minimally using ABCDEI don’t get what you want, sorry mate!$ python3 roman_arabic.pyHow can I help you? Please convert ABCD minimalyI don’t get what you want, sorry mate!$ python3 roman_arabic.pyHow can I help you? Please convert 0I minimallyHey, ask me something that’s not impossible to do!$ python3 roman_arabic.pyHow can I help you? Please convert ABAA minimallyHey, ask me something that’s not impossible to do!$ python3 roman_arabic.pyHow can I help you? Please convert ABCDEFA minimallyHey, ask me something that’s not impossible to do!$ python3 roman_arabic.pyHow can I help you? Please convert MDCCLXXXVII minimallySure! It is 1787 using MDCLXVI$ python3 roman_arabic.pyHow can I help you? Please convert MDCCLXXXIX minimallySure! It is 1789 using MDCLX_I$ python3 roman_arabic.pyHow can I help you? Please convert MMMVII minimallySure! It is 37 using MVI$ python3 r
oman_arabic.pyHow can I help you? Please convert VI minimallySure! It is 4 using IV$ python3 roman_arabic.pyHow can I help you? Please convert ABCADDEFGF minimallySure! It is 49269 using BA_C_DEF_G$ python3 roman_arabic.pyHow can I help you? Please convert ABCCDED minimallySure! It is 1719 using ABC_D_E  

admin

Author admin

More posts by admin