![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
算法题
整数反转,乘法表等等
幽影冥狐
这个作者很懒,什么都没留下…
展开
-
类型转换
字符串转换成整型test_list=['1','3','2','6','8']print("输出test_list: " ,test_list)# out_list=test_listout_list=[]for i in range(0,len(test_list)): #转换成整型,使用int()可以把字符串转换成整型 out_list.append(int(test_list[i]))print("转型后结果: " , out_list)整形转换成字符串原创 2020-12-28 14:41:10 · 135 阅读 · 0 评论 -
求和
1、数组只知道值小于等于100求和L = []B = []x = 1#使用while循环,当不和条件时终止while x <= 100: #使用append() 方法在L[]列表末尾添加新的对象 L.append(x * x) x = x +1 B.append(x)#使用sum()把L[]列表中的对象相加求和print(sum(L))print('叉叉:',B)print('数组:',L)2、已知数组N个值求和L = [1,2,..原创 2020-12-28 01:18:33 · 272 阅读 · 0 评论 -
列表中按要求取值
a=range(1, 101)print(a)b=a[0:10]print('前10个数:',b)c=a[2::3]print('3的倍数:',c)d=a[4:50:5]print('不大于50的5的倍数:',d)原创 2020-12-28 01:19:42 · 363 阅读 · 0 评论