1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Plotting defined function

Discussão em 'Python' iniciado por Stack, Abril 10, 2025.

  1. Stack

    Stack Membro Participativo

    I've defined a function which I would now like to plot:

    import numpy as np
    from math import pi, sqrt
    import matplotlib.pyplot as plt

    def f(x: float) -> float:
    return pi * x * sqrt(x**2 + 400) + pi * x**2 - 1200

    plt.plot(f(x))
    plt.show()


    When running this code, I get "NameError: name 'x' is not defined".

    Continue reading...

Compartilhe esta Página