1.计算圆的面积
import mathprint (math.pi)def area(r): return round(r*r*math.pi,2)print("area=",area(6))print("area=",area(36))
def is_prime(number): if number in(1,2): return True for i in range(2,number): if number%i==0: return False return Truedef print_prime(begin,end): for number in range(begin,end+1): if is_prime(number): print(f"{number} is prime") begin=1end=25print_prime(begin,end)
求N个数字的平均和
def pingfanghe(n): result=0 for number in range(1,n+1): result=result+number*number return resultn=5print(f"{n}个数字的平方和是",pingfanghe(n))
转载此文是出于传递更多信息目的。若来源标注错误或侵犯了您的合法权益,请与本站联系,我们将及时更正、删除、谢谢。
https://www.414w.com/read/638869.html