我正在做一個介紹類,他們要求我重複一個函數一定的時間,因爲我說這是一個介紹,所以大部分代碼都是這樣寫的功能已被定義。我必須重複tryConfiguration(floorplan,numLights)
時間量numTries
請求。任何幫助都會很棒:D謝謝。在python中重複函數一段時間
def runProgram():
#Allow the user to open a floorplan picture (Assume the user will select a valid PNG floodplan)
myPlan = pickAFile()
floorplan = makePicture(myPlan)
show(floorplan)
#Display the floorplan picture
#In level 2, set the numLights value to 2
#In level 3, obtain a value for numLights from the user (see spec).
numLights= requestInteger("How many lights would you like to use?")
#In level 2, set the numTries to 10
#In level 3, obtain a value for numTries from the user.
numTries= requestInteger("How many times would you like to try?")
tryConfiguration(floorplan,numLights)
#Call and repeat the tryConfiguration() function numTries times. You will need to give it (pass as arguments or parameterS)
# the floorplan picture that the user provided and the value of the numLights variable.
使用'for'循環。 – rlms
我們很樂意在StackOverflow上幫助您解決這些問題,但請發佈您迄今爲止所嘗試的內容。 –