【发布时间】:2020-06-08 22:57:03
【问题描述】:
所以我正在做一项任务,我需要找到停车场中占用空间的百分比,我有我的清单和百分比计算。当我运行程序时,我得到 0%。
我认为我做错了什么,因为列表没有被选中。
只是寻找一些提示和技巧,而不是完整的答案:)
#Find the percentage of occupied car spaces.
#Input: Cars in spaces
occupied_spaces = [1, 1, 1, 1, 1, 1, 0, 0, 0 ,0, 0]
#Output: of spaces occupied
spaces = 0
cars = 1
#calualtion to find percentage
percentage = (spaces/(cars)*100)
print (percentage,'% of spaces are occupied')
【问题讨论】:
-
那么
1的意思就是空间被占用了吧? -
是的,抱歉我没有解释清楚