【Python】找规律_01
2022/4/27 14:13:53
本文主要是介绍【Python】找规律_01,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
2 打印 2,3
3 打印 2,3,4
4 打印 2,3,4,5
……依次类推
def test_debug(self, n): """ 2 打印 2,3 3 打印 2,3,4 4 打印 2,3,4,5 ……依次类推 :return: """ if n >= 2: i_list = [] for i in range(1, n+1): i_list.append(i+1) print("n = {}, 输出:{}".format(n, i_list)) else: print("请输入大于2的正整数") if __name__ == "__main__": print("") test_debug(n=3) test_debug(n=4) test_debug(n=5) test_debug(n=8)
结果:
这篇关于【Python】找规律_01的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 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