我们有这个任务,我花一些时间就可以了...
测试脚本要我们把它打印出来:打印表,而模块
>>> input([0, 1, 2, 3])
x | sin(x) | cos(x) | tan(x)
---------------------------------
0.00 | 0.00 | 1.00 | 0.00
1.00 | 0.84 | 0.54 | 1.56
2.00 | 0.91 | -0.42 | -2.19
3.00 | 0.14 | -0.99 | -0.14
不使用模块(我们可以只使用模块MATH使用此作为提示 https://docs.python.org/3/library/string.html#format-specification-mini-language
请帮 这是我现在有:
import math
def input(list):
rad=[]
sinvr=[]
cosvr=[]
tanvr=[]
for el in list:
sin=math.sin(el)
sinvr.append(sin)
cos=math.cos(el)
cosvr.append(cos)
tan=math.tan(el)
tanvr.append(tan)
print (" x | sin(x) | cos(x) | tan(x)\n---------------------------------")
如果这是你的方法只是使用字符串格式来设置你的表格的值? –
您的代码只打印表头 –