Tegn en graf ut ifra en verditabell.

Vi importerer funksjonen pyplot fra biblioteket matplotlib.

from matplotlib import pyplot

x = []

y = []

for i in range(1,5):

x.append(i)

y.append(2*i+3)

print("x",x)

print("y",y)

pyplot.title("Grafen til y=2x+3")

pyplot.xlabel("x-akse")

pyplot.ylabel("y-akse")

pyplot.plot(x,y)

pyplot.show()

Koden gir denne utskriften: