Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
402 B
1
Indexable
Never
import matplotlib.pyplot as plt

# Define the function
def f(x):
    return 0.3 * (x - 4)

# Define the x values
x = [0, 1, 2, 3, 4, 5]

# Calculate the y values
y = [f(i) for i in x]

# Plot the function
plt.plot(x, y, 'ro-')

# Set the x and y limits
plt.xlim(0, 5)
plt.ylim(-1, 1)

# Set the x and y labels
plt.xlabel('x')
plt.ylabel('0.3(x - 4)')

# Show the plot
plt.show()
Leave a Comment