Let R be a commutative ring. The total graph of R, denoted by TΓ(R) is a graph whose vertices are all elements of the ring R and every i,j∈R with i≠j, then i and j vertices are connected by edges if and only if i+j∈Z(R), where Z(R) is the set of zero-divisors in R with 0∈Z(R). Python programming is code that is easy to learn, read, understand, and helpful in explaining problems regarding graphs and algebra. In this paper, we determine an algorithm to construct the total graph of ring Z_n using Python. The research methods in this paper is a literature studies. The results generated by the algorithm can be utilized to observe the characteristic patterns displayed by the graph. Based on the algorithm’s constructed graph pattern, several properties of TΓ(Z_n ) can be inferred. For instance, if n is a prime number, then TΓ(Z_n ) is a disconnected graph. On the other hand, if n is a prime number and n≥3, then TΓ(Z_2n ) and TΓ(Z_4n ) is a connected graph, regular graph, Hamiltonian graph, and has a girth gr(TΓ(〖Z〗_n ))=3. In this paper we creating an algorithm to construct total graphs from commutative rings streamlines the construction process, enhances accessibility and utilization of total graphs, and supports parameter variation exploration and application in problem-solving.