NP96. 球的表面积
描述
输入描述
无输出描述
每行输出一个表面积,保留两位小数。Python 解法, 执行用时: 10ms, 内存消耗: 2972KB, 提交时间: 2022-07-27
import math def area(r): s=4*math.pi*r*r return s print(round(area(1),2)) print(round(area(2),2)) print(round(area(4),2)) print(round(area(9),2)) print(round(area(10),2)) print(round(area(13),2))
Python 解法, 执行用时: 11ms, 内存消耗: 2856KB, 提交时间: 2022-07-27
import math def area(r): s=4*math.pi*r*r return s print(round(area(1),2)) print(round(area(2),2)) print(round(area(4),2)) print(round(area(9),2)) print(round(area(10),2)) print(round(area(13),2))
Python 解法, 执行用时: 11ms, 内存消耗: 2868KB, 提交时间: 2022-07-28
from math import pi def surface_area(radius): return 4 * pi * radius * radius radius_list = [1, 2, 4, 9, 10, 13] for i in radius_list: print(round(surface_area(i), 2))
Python 解法, 执行用时: 11ms, 内存消耗: 2976KB, 提交时间: 2022-08-02
import math as mt def vol(n): return 4*mt.pi*(n**2) list1=[1, 2, 4, 9, 10, 13] for n in list1: print(round(vol(n),2))
Python 解法, 执行用时: 12ms, 内存消耗: 3024KB, 提交时间: 2022-08-02
import math r_s = [1, 2, 4, 9, 10, 13] def s_qiu(r): s = 4*math.pi*r**2 return s #for i in r_s: # print('%.2f' % s_qiu(int(i))) m=map(s_qiu,r_s) for i in m: print('%.2f' % i)