三角函数图形与python龟。

时间:2017-02-19 07:59:00

标签: math python-3.6

我正在尝试使用python turtle来绘制三角函数,但它不允许我将浮点数与任何内置函数(正弦,余弦,正切,.etc)相乘。我想为基本的图形公式做一个 math.sin((b x)-c)+ d。有没有办法执行这个?非常感谢 :) 这是我目前的代码:

enter code here
x= -2*(math.pi)
A=float(input('What is the amplitude? '))
b=float(input('What is the b-value? '))
c=float(input('What is the horizontal shift? '))
d=float(input('What is the vertical shift? '))
period=(2*(math.pi)/b)
y = A*(math.sin((period*x-c)+d))
t.penup()
t.goto(x,y)
t.pendown()
x=(-23*(math.pi)/12)
while x!= 2*(math.pi):
    y = A*(math.sin)*((period*x-c)+d)
    t.goto(x,y)
    x = x+((math.pi)/12)

1 个答案:

答案 0 :(得分:0)

您在y变量的第二个声明中出现语法错误。您应该使用与第一个声明相同的语法来纠正此问题。

enter code here
x= -2*(math.pi)
A=float(input('What is the amplitude? '))
b=float(input('What is the b-value? '))
c=float(input('What is the horizontal shift? '))
d=float(input('What is the vertical shift? '))
period=(2*(math.pi)/b)
y = A*(math.sin((period*x-c)+d))
t.penup()
t.goto(x,y)
t.pendown()
x=(-23*(math.pi)/12)
while x!= 2*(math.pi):
    y = A*(math.sin((period*x-c)+d))
    t.goto(x,y)
    x = x+((math.pi)/12)
相关问题