以下是科大「COMP1021」課程本學年的期中考試題目改成巴士相關:
A KMB bus captain, scheduled to route 88K, uses a Python program to determine which bus he should drive for the day. The program is as follows:
import random
avbe=["MT593", "MT943", "MW4225", "MX1419"]
atenu=["TX5684", "UH7152", "UU4653", "SV4082"]
bus_choice = []
for i in range (2):
index=random.randint(0, len(avbe)-1)
selected_bus=avbe[index]
bus_choice.append(selected_bus)
avbe.remove(selected_bus)
print("Bus", selected_bus, "is chosen.")
index=random.randint(0, len(atenu)-1)
selected_bus=atenu[index]
bus_choice.append(selected_bus)
atenu.remove(selected_bus)
print("Bus", selected_bus, "is chosen.")
index=random.randint(0, len(bus_choice)-1)
bus_used=bus_choice[index]
print("Bus", index, "is chosen, so you are going to drive", bus_used, "today".)
If buses 0 for avbe and atenu were drawn first, followed by buses 1 in the revised lists, then bus 2 is drawn from the final list, which bus is the driver using today?
你們有沒有一些可以改成巴士相關的題目? |
|
|
|
|
|
Advertisement
Advertisement
Advertisement
Advertisement
Advertisement
|