我的编程空间,编程开发者的网络收藏夹
学习永远不晚

新南威尔士大学COMP9021Assi

短信预约 -IT技能 免费直播动态提醒
省份

北京

  • 北京
  • 上海
  • 天津
  • 重庆
  • 河北
  • 山东
  • 辽宁
  • 黑龙江
  • 吉林
  • 甘肃
  • 青海
  • 河南
  • 江苏
  • 湖北
  • 湖南
  • 江西
  • 浙江
  • 广东
  • 云南
  • 福建
  • 海南
  • 山西
  • 四川
  • 陕西
  • 贵州
  • 安徽
  • 广西
  • 内蒙
  • 西藏
  • 新疆
  • 宁夏
  • 兵团
手机号立即预约

请填写图片验证码后获取短信验证码

看不清楚,换张图片

免费获取短信验证码

新南威尔士大学COMP9021Assi

题意:

使用Python解决计算,数据结构和字符串的问题。

解析:

三个问题都涉及字符串处理的问题,将对应的字符转换为整数。

对于本程序,用户应该有三种输入,除了以外的输入程序应该进行提示,这三种输入对应的输出为: 1.Please convert ***:***代表罗马数字或整数,程序应该将罗马数字转换为正整数[0,3999]然后也能将整数转换为罗马数字,之后停止。 2.Please convert *** using ***,第一个***代表原本的罗马数字序列,第二个***表示指定的罗马数字序列表,该程序目的是将罗马序列用指定的序列进行转换成整数,从右到左按照(1,5,10,50,100,500,1000)的排序。如果程序不能进行转化,则进行一些输出。 3.Please convert *** minimally,将***代表的罗马数字,程序先查看这个罗马数字能否使用一般性的序列表(MDCLXVI)或其他序列表进行转换,如果能则将其转换为一个尽量小的正整数,并且输出这个序列表。

 涉及知识点:

Python,字符串

更多可加微信讨论

微信号:tiamo-0620

pdf

Assignment 1

COMP9021, Term 3, 2019

1. General matters

1.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 developed

and tested your program, upload it using WebCMS. Assignments can be submitted more than once; the last

version 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. For

each 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 mark

and 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 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 routinely 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 user input is not of this form, with any occurrence of *** an arbitrary nonempty sequence of nonspace

symbols, then the program should print out

I 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 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 ***

1

2

2.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 (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 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 of

generalised 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 from

generalised Roman to Arabic, then the program should print out

Hey, 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 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 fnd 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 ***

2.4. Sample outputs. 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!

$ python3 roman_arabic.py

How can I help you? Please convert IXI

Hey, ask me something that's not impossible to do!

$ python3 roman_arabic.py

3

How can I help you? Please convert 35

Sure! It is XXXV

$ python3 roman_arabic.py

How can I help you? Please convert 1982

Sure! It is MCMLXXXII

$ python3 roman_arabic.py

How can I help you? Please convert 3007

Sure! It is MMMVII

$ python3 roman_arabic.py

How can I help you? Please convert MCMLXXXII

Sure! It is 1982

$ python3 roman_arabic.py

How can I help you? Please convert MMMVII

Sure! It is 3007

$ python3 roman_arabic.py

How can I help you? Please convert 123 by using ABC

I don't get what you want, sorry mate!

$ python3 roman_arabic.py

How can I help you? Please convert 123 ussing ABC

I don't get what you want, sorry mate!

$ python3 roman_arabic.py

How can I help you? Please convert XXXVI using VI

Hey, ask me something that's not impossible to do!

$ python3 roman_arabic.py

How can I help you? Please convert XXXVI using IVX

Hey, ask me something that's not impossible to do!

$ python3 roman_arabic.py

How can I help you? Please convert XXXVI using XWVI

Hey, ask me something that's not impossible to do!

$ python3 roman_arabic.py

How can I help you? Please convert I using II

Hey, ask me something that's not impossible to do!

$ python3 roman_arabic.py

How can I help you? Please convert _ using _

Hey, ask me something that's not impossible to do!

$ python3 roman_arabic.py

How can I help you? Please convert XXXVI using XVI

Sure! It is 36

$ python3 roman_arabic.py

How can I help you? Please convert XXXVI using XABVI

Sure! It is 306

$ python3 roman_arabic.py

How can I help you? Please convert EeDEBBBaA using fFeEdDcCbBaA

Sure! It is 49036

$ python3 roman_arabic.py

How can I help you? Please convert 49036 using fFeEdDcCbBaA

Sure! It is EeDEBBBaA

$ python3 roman_arabic.py

How can I help you? Please convert 899999999999 using AaBbCcDdEeFfGgHhIiJjKkLl

Sure! It is Aaaabacbdcedfegfhgihjikjlk

$ python3 roman_arabic.py

How can I help you? Please convert ABCDEFGHIJKLMNOPQRST using AbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStT

Sure! It is 11111111111111111111

$ python3 roman_arabic.py

4

How can I help you? Please convert 1900604 using LAQMPVXYZIRSGN

Sure! It is AMAZING

$ python3 roman_arabic.py

How can I help you? Please convert ABCD minimally using ABCDE

I don't get what you want, sorry mate!

$ python3 roman_arabic.py

How can I help you? Please convert ABCD minimaly

I don't get what you want, sorry mate!

$ python3 roman_arabic.py

How can I help you? Please convert 0I minimally

Hey, ask me something that's not impossible to do!

$ python3 roman_arabic.py

How can I help you? Please convert ABAA minimally

Hey, ask me something that's not impossible to do!

$ python3 roman_arabic.py

How can I help you? Please convert ABCDEFA minimally

Hey, ask me something that's not impossible to do!

$ python3 roman_arabic.py

How can I help you? Please convert MDCCLXXXVII minimally

Sure! It is 1787 using MDCLXVI

$ python3 roman_arabic.py

How can I help you? Please convert MDCCLXXXIX minimally

Sure! It is 1789 using MDCLX_I

$ python3 roman_arabic.py

How can I help you? Please convert MMMVII minimally

Sure! It is 37 using MVI

$ python3 roman_arabic.py

How can I help you? Please convert VI minimally

Sure! It is 4 using IV

$ python3 roman_arabic.py

How can I help you? Please convert ABCADDEFGF minimally

Sure! It is 49269 using BA_C_DEF_G

$ python3 roman_arabic.py

How can I help you? Please convert ABCCDED minimally

Sure! It is 1719 using ABC_D_E

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

新南威尔士大学COMP9021Assi

下载Word文档到电脑,方便收藏和打印~

下载Word文档

猜你喜欢

新南威尔士大学COMP9021Assi

题意:使用Python解决计算,数据结构和字符串的问题。解析:三个问题都涉及字符串处理的问题,将对应的字符转换为整数。对于本程序,用户应该有三种输入,除了以外的输入程序应该进行提示,这三种输入对应的输出为: 1.Please convert
2023-01-31

2021年9月黑龙江哈尔滨工业大学威海学院计算机等级考试报名通知

  2021年9月全国计算机等级考试报名工作正在进行中,为了方便广大考生及时获取报名的实时信息,今天编程学习网小编为您精心整理了2021年9月黑龙江哈尔滨工业大学威海学院计算机等级考试报名通知,希望广大考生及时关注,更多计算机等级考试的相关资讯,请关注编程学习网网站的更新。  根据教育部考试中心统一安排,山东省2021年9月全
2021年9月黑龙江哈尔滨工业大学威海学院计算机等级考试报名通知
2024-04-18

2022年9月黑龙江哈尔滨工业大学(威海)全国计算机等级考试报名通知

  2022年9月全国计算机等级考试报名工作正在进行中,为了方便广大考生及时获取报名的实时信息,下面编程学习网小编为您精心整理了2022年9月黑龙江哈尔滨工业大学(威海)全国计算机等级考试报名通知,希望广大考生及时关注,更多计算机等级考试的相关资讯,请关注编程学习网网站的更新。  根据教育部考试中心统一安排,山东省2022年9
2022年9月黑龙江哈尔滨工业大学(威海)全国计算机等级考试报名通知
2024-04-19

编程热搜

  • Python 学习之路 - Python
    一、安装Python34Windows在Python官网(https://www.python.org/downloads/)下载安装包并安装。Python的默认安装路径是:C:\Python34配置环境变量:【右键计算机】--》【属性】-
    Python 学习之路 - Python
  • chatgpt的中文全称是什么
    chatgpt的中文全称是生成型预训练变换模型。ChatGPT是什么ChatGPT是美国人工智能研究实验室OpenAI开发的一种全新聊天机器人模型,它能够通过学习和理解人类的语言来进行对话,还能根据聊天的上下文进行互动,并协助人类完成一系列
    chatgpt的中文全称是什么
  • C/C++中extern函数使用详解
  • C/C++可变参数的使用
    可变参数的使用方法远远不止以下几种,不过在C,C++中使用可变参数时要小心,在使用printf()等函数时传入的参数个数一定不能比前面的格式化字符串中的’%’符号个数少,否则会产生访问越界,运气不好的话还会导致程序崩溃
    C/C++可变参数的使用
  • css样式文件该放在哪里
  • php中数组下标必须是连续的吗
  • Python 3 教程
    Python 3 教程 Python 的 3.0 版本,常被称为 Python 3000,或简称 Py3k。相对于 Python 的早期版本,这是一个较大的升级。为了不带入过多的累赘,Python 3.0 在设计的时候没有考虑向下兼容。 Python
    Python 3 教程
  • Python pip包管理
    一、前言    在Python中, 安装第三方模块是通过 setuptools 这个工具完成的。 Python有两个封装了 setuptools的包管理工具: easy_install  和  pip , 目前官方推荐使用 pip。    
    Python pip包管理
  • ubuntu如何重新编译内核
  • 改善Java代码之慎用java动态编译

目录