![](https://csdnimg.cn/release/download_crawler_static/22694355/bg1.jpg)
使用 python 绘制正余弦函数
要求最终效果如下:
代码:
from turtle import*
from math import sin,cos,pi
print("I will draw the image of y=AcosBx+C for you")
def judge(s):
c=input(f"Please enter the {s}!")
if s=="function type":
while True:
if c=="sin" or c=="cos":
return c
else:
c=input(f"Please enter the {s}!")
while True:
try:
c=float(c)
return c
except:
c=input(f"Please enter the {s}!")
A,B,C,ft=judge("A"),judge("B"),judge("C"),judge("function type")
setpos(0,75*(A+C)/pi)
write(f"{A+C}")