我还想输入十进制数。我试过用float
,但没用
下面是我需要更正的代码:
a = input()
b = input()
list1 = list(map(int, a.split()))
list2 = list(map(int, b.split()))
garums1 = len(list1)
garums2 = len(list2)
summa=0
for i in range(len(list1)):
if garums1==garums2:
summa=list1[i]/list2[i]
print(round(summa,1), end=" ")
代码工作
1 2 3 4
2 3 4 5
0.5 0.7 0.8 0.8
也需要这样的东西
1.23 4.1 51.3 44
2 4.1 4 5
0.6 1.0 12.8 8.8
只需将映射从
int
更改为float
:对于
list1
和list2
,请尝试:希望这有帮助
相关问题 更多 >
编程相关推荐