A small Python program for rendering text-based function graphs in the console.
- Python 3.8 or later
- No external dependencies required (uses the standard library only)
- Open a terminal.
- Change to the project directory:
cd /path/to/Plot-function-graphs - Run the script:
python draw.py
When you run draw.py, the program will prompt you for:
Enter a function f(x) =— a math expression in terms ofxEnter domain start:— integer start value for the x domainEnter domain end:— integer end value for the x domainEnter x axis scale:— numeric scale factor for x valuesEnter y axis scale:— numeric scale factor for y values
The program accepts expressions such as:
x^2sin(x)cos(x)sqrt(x)abs(x)fact(x)gamma(x)
Enter a function f(x) = x^2
Enter domain start: -2
Enter domain end: 2
Enter x axis scale: 5
Enter y axis scale: 5
The script will then print a text-based graph using * for points and | / - for the axes.
- Use Python-style function notation where needed.
- Multiplication is inferred in many cases, but explicit
*can improve reliability. - If parentheses are mismatched or unsupported characters are used, the program will ask you to correct the function format.