好了,所以這裏是賦值:課堂作業:比賽時間,分揀
You're a swimmer, and you want to compare all of your race times to find the >fastest one. Write a program that continuously takes race times as doubles >from standard input, until the input is "no more races," at which point it >should print out the time of your fastest race.
相當簡單的,我這樣想着。通過一些工作,我想出了以下幾點:
race_time = input("")
list1=[]
while race_time != ("no more races"):
list1.append("")
if race_time == ("no more races"):
print(min(list1))
好的,所以要求輸入。只要race_time中的輸入不等於「沒有更多的比賽」,您就輸入下一次,並將該值附加到list1。一旦race_time等於「不再有比賽」,則從list1打印最小值。
直截了當吧?
嗯,我毫不猶豫地掏出代碼爲MyProgrammingLab並提交。它給了我以下...'反饋'
Your code did not work as expected. More Hints: ⇒ We think you might want to consider using: float ⇒ Solutions with your approach don't usually use: == ⇒ Solutions with your approach don't usually use: if
好吧......那我爲什麼要用這些?
無論如何,所以我扔的代碼進入空閒並運行它。這裏我得到以下錯誤:
Traceback (most recent call last): File "C:\Users\F2-233\Desktop\times.py", line 4, in list1.append("") MemoryError
那麼...什麼是追溯?這本書還沒有談到這一點,並在網上搜索,我發現很多的代碼示例來解決這一問題,但沒有發現的問題是什麼的解釋。
是它的內存限制我在代碼中實現或者是一個系統限制? –
你的上限取決於您的環境=>操作系統,Python運行時(Jython中,activatestate,純Python等),32位VS 64位進程等 – axlj