下面是我一直坚持的任务,我用python
来实现它:
First, take the input array values from the first loop sequence and set them up so that a mathematical function (like add) is done with the values, then output to screen. Loop back to do a different function with the values. In total, use all four functions. Take a screenshot and note on the results.
这是我当前的代码:
a = input('Enter a value: ')
b = input('Enter a value: ')
c = input('Enter a value: ')
d = input('Enter a value: ')
e = input('Enter a value: ')
f = input('Enter a value: ')
g = input('Enter a value: ')
h = input('Enter a value: ')
i = input('Enter a value: ')
j = input('Enter a value: ')
list1 = [a, b, c, d, e, f, g, h, i, j]
again = input("Do you want to do some math?")
if again == "y":
add = (list1 + list1)
print (add)
again = input ("Want to play again? y/n")
elif again == "n":
sub = (list1 - list1)
print (sub)
else:
mult = (list1 * list1)
print (mult)
break
我需要用户输入10个数字,这是保存到一个数组变量。在那之后,我需要创建一个循环来执行一个数学函数(即Add),然后循环回来执行另外3个函数(即Sub、Mult和Div)。你知道吗
我想这就是你的要求:
有什么问题请问!你知道吗
我相信这就是你想要的,虽然可能数学函数可能不同,但无论哪种方式,如果你用模块化的方式做东西会更好,这样更容易阅读
相关问题 更多 >
编程相关推荐