python 匿名函数实现求素数平方和
sq=lambda x:x**2def list_prime(*data): list1=[] list2=[] for i in data: list1.append(i) for i in range(len(list1)): a=0 for j in range(2,list1[i]): if list1[i]%j==0: a=1 break if a==0 and list1[i]>1: list2.append(list1[i]) return list2c=list(map(int, input("请输入一串数字(用空格分隔):").split()))print("素数有:{}".format(list_prime(*c)))list3=[]for i in list_prime(*c): list3.append(i)print("素数的平方和分别为:{}".format(list3))
相关推荐
meylovezn 2020-09-21
usepython 2020-05-28
举 2020-05-20
amazingbo 2020-02-26
牵手白首 2020-02-01
wklken的笔记 2020-01-30
sulindong0 2020-01-19
chinademon 2020-01-12
wyqwilliam 2020-01-02
Yellowpython 2020-01-08
JasonYeung 2019-12-28
xiaoge00 2019-12-21
NameCHC 2019-12-05
xcguoyu 2019-11-12
wyqwilliam 2019-11-05
banzhihuanyu 2019-11-01
codeAB 2019-10-26