我需要计算一下总的楼层面积。它首先询问房间的数量(所有房间都是矩形的),然后使用for循环询问每个房间的长度和宽度。以下是我的代码(python):
norooms = int(input('How many rooms does the floor have?'))
length = dict()
width = dict()
for i in range(norooms):
length[i] = input('what is the length of room?')
width[i] =input('what is the width of room?')
print('that was room number:',i+1)
现在我得计算一下地板的总数。我能帮个忙吗?在
如果它在Programming Exchange中,我建议改为使用以下代码:
^{pr2}$使用
numpy
可以很快解决这个问题。如果你将来要做类似的事情,花点时间学习图书馆也许是值得的。在不管怎样,给你:
你知道怎样计算给定房间的面积?对所有房间都这样做,然后计算总数。还要注意,目前房间的长度和宽度仍然是字符串。在
相关问题 更多 >
编程相关推荐