摘要: 代码: def remove_elements_from_list(i,j): for itam in j: i.remove(itam) return i lista=[3,5,7,9,11,13] listb=[7,11] print(f"from {lista} remove {listb}, 阅读全文
posted @ 2021-10-18 21:46 scholar-for-ever 阅读(30) 评论(0) 推荐(0) 编辑
摘要: 代码: def get_even_numbers(i,j): result=[] for item in range(i,j): if item % 2==0: result.append(item) return result begin=4 end=15 data=[item for item 阅读全文
posted @ 2021-10-18 21:25 scholar-for-ever 阅读(29) 评论(0) 推荐(0) 编辑
摘要: 代码: def sum_list(n): result=0 for i in n: result+=i return result list1=[1,2,3,4] list2=[17,5,3,5] print(f"The sum of {list1} is:" ,sum_list(list1)) p 阅读全文
posted @ 2021-10-18 20:42 scholar-for-ever 阅读(26) 评论(0) 推荐(0) 编辑
摘要: 代码1: 1 def sum_of_square(n): 2 result=0 3 while n>0: 4 result+=n**2 5 n-=1 6 return result 7 8 print("Sum of square (3) is: " ,sum_of_square(3)) 9 pri 阅读全文
posted @ 2021-10-18 08:07 scholar-for-ever 阅读(34) 评论(0) 推荐(0) 编辑