python 接收不固定行数的矩阵输入
2022/5/28 1:50:08
本文主要是介绍python 接收不固定行数的矩阵输入,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
Reference Link:
Python中如何获取二维列表的行数和列数
python 判断矩阵为空
python 接收不固定行数的矩阵输入
正文
ls = [] input1 = list(map(int,input().strip().split())) # 空行作为循环停止的判定 # https://blog.csdn.net/R72692/article/details/119352176 # python 判断矩阵为空 # https://blog.csdn.net/u012759006/article/details/89177135 while any(input1): ls.append(input1) print(ls) input1 = list(map(int,input().strip().split())) print(len(ls)) # Python中如何获取二维列表的行数和列数 print(len(ls[0])) # Python中如何获取二维列表的行数和列数 for i in range(len(ls)): kk = [] kk.append(ls[i][0]) for j in range(ls[i][1]-1): kk.append(math.sqrt(kk[j])) print("{:.2f}".format(sum(kk)))
运行结果如下:
这篇关于python 接收不固定行数的矩阵输入的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-08有遇到过吗?同样的规则 Excel 中 比Python 结果大
- 2024-03-30开始python成长之路
- 2024-03-29python optparse
- 2024-03-29python map 函数
- 2024-03-20invalid format specifier python
- 2024-03-18pool.map python
- 2024-03-18threads in python
- 2024-03-14python Ai 应用开发基础训练,字符串,字典,文件
- 2024-03-13id3 algorithm python
- 2024-03-13sum array elements python