Math 用python绘制三角函数图。

Math 用python绘制三角函数图。,math,python-3.6,Math,Python 3.6,我试图使用python turtle绘制三角函数,但它不允许我将浮点与任何内置函数(正弦、余弦、切线等)相乘。我想用Amath.sin((bx)-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

我试图使用python turtle绘制三角函数,但它不允许我将浮点与任何内置函数(正弦、余弦、切线等)相乘。我想用Amath.sin((bx)-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)

第二次声明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)

我很感激。但是,使用相同的语法是什么意思?很抱歉我是编程新手。语法只是一个基本意思是“你写它的方式”的词。在y的第一个声明中,您将y=A*(math.sin((句点*x-c)+d)),这是正确的。在第二个声明中,您将
y=A*(math.sin)*((句点*x-c)+d)
,这不是编写
math.sin()
函数的正确方法很高兴它对你有用。