Python到OAM汇编语言

Python到OAM汇编语言,python,assembly,oam,Python,Assembly,Oam,我正在尝试将python程序转换为汇编语言,但我不确定如何转换。下面是python程序: numberofscores=float(input("Please enter the number of test scores to be entered:")) sumofscores = 0 count = 1 while count <= numberofscores : score1=float(input("Please enter the test score:"))

我正在尝试将python程序转换为汇编语言,但我不确定如何转换。下面是python程序:

numberofscores=float(input("Please enter the number of test scores to be entered:"))
sumofscores = 0
count = 1
while count <= numberofscores :
      score1=float(input("Please enter the test score:"))
      sumofscores=sumofscores+score1
      count=count+1
average=sumofscores/numberofscores 
print average 
numberofscores=float(输入(“请输入要输入的考试分数:”)
堆芯总和=0
计数=1

虽然countHmm,但我从未听说过这个教学资源,它是基于网络的
OAMulator
(,),支持
OAMPL
(OAM编程语言)和(编译)到
OAM汇编

所以我作弊了..
首先,我“解析”了您的python代码(我也不懂python),并将其翻译为
OAMPL

PRINT "Please enter the number of test scores to be entered:"
READ numberofscores
sumofscores = 0
LOOP numberofscores
  PRINT "Please enter the test score:"
  READ testscore
  sumofscores = (+ sumofscores testscore)
END
PRINT "the answer is:"
PRINT (/ sumofscores numberofscores)
EXIT
注意:我没有翻译你的
float
,因为它应该是
int
(尽管每个分数都可以是float)。经过一些测试后,我发现
2.5
的输入无论如何都是以浮点形式“读取”的。我还丢弃了
count
变量(因为
LOOP
指令在没有它的情况下工作)和
average
变量(因为我不需要它)

单击编译呈现(这可能是您的答案)):

给定
输入(每行一个)

注:对询问考试分数的问题回答“3”,然后对询问个别考试分数的问题回答“71.4”、“33”和“21.6”。(这不是交互式输入,这让我耽搁了15分钟……这件事可能会从合并中受益匪浅)

如果我
执行上面的OAM程序集(编译!!)并将上面的输入提供给它,那么输出将呈现:

Please enter the number of test scores to be entered:
Please enter the test score:
Please enter the test score:
Please enter the test score:
the answer is:
42
。。。天哪答案是42,这是所有问题的答案…
(太酷了……没有可用的文档,猜测编程语言……这是我回答过的最酷的问题)

希望这有帮助


PS:请在下面的评论中添加一些指向此OAMPL和OAM程序集的文档/语法的链接我能找到的在线文档(,)没有真正的帮助(例如,
从“hello world”示例中写入的
不起作用..等等。我不知道OAMPL支持什么语法,除了语法)。

可能从OAM手册/参考开始。然后告诉我们你尝试了什么或者你不理解的部分。这是对OAMulator的webiste:我在构建循环或branchingI WILL时遇到了困难!难道没有办法将输入也打印到屏幕上吗?大写PS部分是为任何阅读它的人准备的,并且有一个OAMPL、OAM汇编和OAM指令集参考:我*希望有这些数据,否则我们就不可能帮助未来的学生。*我(当然还有其他人)如果你能在这里分享,我将不胜感激!要将输入也打印到屏幕上,您只需执行以下操作:
print varname
(例如:
print numberofscores
)。既然您不接受这个答案,我可以问一下您不喜欢它的地方吗?另外,请不要忘记将我们链接到您承诺的文档!
3
71.4
33
21.6
Please enter the number of test scores to be entered:
Please enter the test score:
Please enter the test score:
Please enter the test score:
the answer is:
42