LRT610-1092 發表於 2021-10-23 18:36

把一道考試題目改成巴士相關(2)

以下是科大「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
    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
    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

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?

你們有沒有一些可以改成巴士相關的題目?

User12345678910 發表於 2021-10-23 19:15

請使用大部分站友的母語
頁: [1]
查看完整版本: 把一道考試題目改成巴士相關(2)