Почему этот код не работает, когда я пытаюсь построить график?
Я вижу две проблемы: 1) вы, кажется, делаете вещи в неправильном порядке;2) вы ошибочно полагаете, что если у есть f (x), то f (-x) равно -y, что не соответствует действительности:
from turtle import *
m = float(input("What is the slope? "))
b = float(input("What is the y-intercept? "))
x, y = window_width(), window_height()
# Draw Axes
penup()
goto(x / 2, 0)
pendown()
goto(-x / 2, 0)
penup()
goto(0, y / 2)
pendown()
goto(0, -y / 2)
# Plot function
y = int(m * x + b)
penup()
goto(x, y)
x = -x
y = int(m * x + b)
pendown()
goto(x, y)
done()
ИСПОЛЬЗОВАНИЕ
> python3 test.py
What is the slope? 0.5
What is the y-intercept? 100
>
ВЫХОД
![enter image description here](https://i.stack.imgur.com/Shovx.png)