Lotus Valley
International School
Project File
Computer Science
Session: 2025-26
Swarit Acharya | XI Raman | Roll No. 21
Contents
Certificate
Acknowledgement
Introduction
Features
Hardware Used
Software Used
Screenshots
Program Codes
Bibliography
Swarit Acharya | XI Raman | Roll No. 21
Certificate
This is to certify that Swarit Acharya of class
Xl Raman has prepared the Project file for Computer
Science. The project is the result of her efforts and
endeavors. The report is found worthy of acceptance
as the project report under the subject computer
science of class XI. He has prepared the report under
my guidance.
Ms. Parul Kapil
Swarit Acharya | XI Raman | Roll No. 21
Acknowledgement
I would like to express my special thanks of gratitude
to my teacher [Link] KAPIL as well as our
principal [Link] SETH who gave me the golden
opportunity to do this wonderful project in which I
made a sophisticated terminal line grapher, which
also helped me in improving my logical skills - I am
thankful to them. Secondly, I would also like to thank
my parents and friends who helped me a lot in
finalizing this project within the limited time frame.
~ Swarit Acharya
Swarit Acharya | XI Raman | Roll No. 21
Introduction
This program implements a terminal based line
grapher for visualizing mathematical equations. It
takes an equation as input, evaluates it over a defined
range of x values, and renders the corresponding
graph directly in the terminal using text characters.
The grapher maps computed points onto a two
dimensional grid, allowing users to observe the
shape, trend, and behavior of equations without
external plotting libraries. This approach provides a
lightweight and accessible way to analyze equations,
making it useful in environments where graphical
interfaces are unavailable.
Swarit Acharya | XI Raman | Roll No. 21
Features
Multiple equation modes
Terminal based visualization
Dynamic equation evaluation
Custom matrix engine
Vertical line handling
Lightweight and minimal
Structured menu system
Swarit Acharya | XI Raman | Roll No. 21
Hardware Used
Swarit Acharya | XI Raman | Roll No. 21
Software Used
Neovim - code editor
Windows 11 as my
operating system
Swarit Acharya | XI Raman | Roll No. 21
Screenshots
Swarit Acharya | XI Raman | Roll No. 21
Screenshots
Swarit Acharya | XI Raman | Roll No. 21
Screenshots
Swarit Acharya | XI Raman | Roll No. 21
Code
"""
Sophisticated & minimal terminal utility for line graphing.
"""
import random
import math
# =======================
# Equation metadata
# =======================
EQUATIONS = {
"slope": {
"name": "Slope Intercept Form",
"formula": "y = mx + c"
},
"positional": {
"name": "Two Point Form",
"formula": "(y - y1) = m(x - x1)"
},
"free": {
"name": "General Form",
"formula": "Ax = By + c"
},
"const_x": {
"name": "Vertical Line",
"formula": "x = k"
},
"const_y": {
"name": "Horizontal Line",
"formula": "y = k"
Swarit Acharya | XI Raman | Roll No. 21
Code
# =======================
# Matrix class
# =======================
class Matrix:
def __init__(self, rows, cols, filler=" "):
[Link] = rows
[Link] = cols
[Link] = filler
[Link] = rows * cols
[Link] = [
[[[Link]] for _ in range(cols)]
for _ in range(rows)
def render(self):
for row in [Link]:
for cell in row:
print(cell[0], end=" ")
print("\n")
def update(self, pos, val="*"):
r, c = pos
if 0 <= r < [Link] and 0 <= c < [Link]:
[Link][r][c] = [val]
def distribute(self, n_lvl, symbol="-"):
for _ in range(int([Link] * n_lvl)):
r = [Link](0, [Link] - 1)
c = [Link](0, [Link] - 1)
[Link][r][c] = [symbol]
def data(self):
return ([Link], [Link], [Link], [Link], [Link])
Swarit Acharya | XI Raman | Roll No. 21
Code
# =======================
# Graph setup
# =======================
rows = 10
cols = 40
graph = Matrix(rows, cols)
# =======================
# Graphing modes
# =======================
def positional():
print(EQUATIONS["positional"]["name"], "-", EQUATIONS["positional"]["formula"])
x1 = int(input("X of first coordinate: "))
y1 = int(input("Y of first coordinate: "))
x2 = int(input("X of second coordinate: "))
y2 = int(input("Y of second coordinate: "))
if x2 == x1:
print("Vertical line detected")
for y in range(rows):
[Link]((y, x1))
[Link]()
return
m = (y2 - y1) / (x2 - x1)
for x in range(cols):
y = int(m * (x - x1) + y1)
[Link]((y, x))
print("\n" * 5)
[Link]()
Swarit Acharya | XI Raman | Roll No. 21
Code
def slope():
print(EQUATIONS["slope"]["name"], "-", EQUATIONS["slope"]["formula"])
m = float(input("Enter slope: "))
c = float(input("Enter y-intercept: "))
for x in range(cols):
y = int(m * x + c)
[Link]((y, x))
print("\n" * 5)
[Link]()
def free():
print(EQUATIONS["free"]["name"], "-", EQUATIONS["free"]["formula"])
A = int(input("Enter x coefficient (A): "))
B = int(input("Enter y coefficient (B): "))
c = int(input("Enter c: "))
if B == 0:
print("Invalid equation")
return
for x in range(cols):
y = int(((A * x) - c) / B)
[Link]((y, x))
print("\n" * 5)
[Link]()
Swarit Acharya | XI Raman | Roll No. 21
Code
def const():
axis = input("Which axis is constant? x or y: ").strip().lower()
const_val = int(input("Enter constant value: "))
if axis == "y":
print(EQUATIONS["const_y"]["name"], "-", EQUATIONS["const_y"]["formula"])
for x in range(cols):
[Link]((const_val, x))
elif axis == "x":
print(EQUATIONS["const_x"]["name"], "-", EQUATIONS["const_x"]["formula"])
for y in range(rows):
[Link]((y, const_val))
else:
print("Invalid axis")
print("\n" * 5)
[Link]()
# =======================
# Menu system
# =======================
COMMANDS = {
"a": slope,
"b": positional,
"c": free,
"d": const
[Link]()
Swarit Acharya | XI Raman | Roll No. 21
Code
print("Welcome to this line grapher. Let's begin")
choice = input(
"How would you like to proceed:\n"
"(a) Slope input\n"
"(b) Two Positional Input\n"
"(c) Equation\n"
"(d) Constant Lines\n\n"
"Enter option: "
).strip().lower()
if choice in COMMANDS:
COMMANDS[choice]()
else:
print("Invalid option")
Swarit Acharya | XI Raman | Roll No. 21
BIBLIOGRAPHY
[Link]
[Link]
Swarit Acharya | XI Raman | Roll No. 21