first_num = raw input ("Please input first number. ")
sec_num = raw input (" Please input second number:")
answer = into( first_num) +into( sec_num)
print " Now I will add your two numbers : ", answer
print " Pretty cool. huh ?
print " Now I'll count backwards from ",answer
counter = answer
while (counter >=0):
print counter
counter = counter-1
print " All done !"
我认为在命令的前半部分添加第一个和第二个数字以获得总和,而后半部分是一个返回开始或归零的命令。我不懂python语言。
答案 0 :(得分:1)
您应该首先尝试运行代码并使用它来理解它。代码很简单;前半部分取两个用户输入并相互添加,然后显示结果。
first_num = input("Please input first number:") # get first number input
sec_num = input("Please input second number:") # get second number input
answer = int(first_num) +int(sec_num) # add up int values of the numbers
print(" Now I will add your two numbers : ", answer) # display answer
至于下半场,它需要一个数字,它向下计数到零
print("Now I'll count backwards from ", answer)
counter = answer # set counter start value
while(counter >=0):
print(counter) # display counter value on each iteration
counter = counter-1 # decrement counter value on each iteration
print(" All done !)
我改变了你的代码,因为你的线条有点乱,有些不正确。我的这个版本适用于python3和 NOT python2.7。如果你想学习python,我建议你从code academy python tutorial
开始