############################################################ # COMPUTER SCIENCE UNDERGRADUATE SCHOLARSHIP EXAM # UNIVERSITY OF WAIKATO # PYTHON PROGRAMMING LANGUAGE # JULIANO TAVARES (TAURANGA BOYS' COLLEGE YR 13) ############################################################ # Import modules import sys # Welcome user print("Welcome to Visualising Graphs") # Build the backend of the grid for the graph def main(): graph_grid = [[0, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1], ] # Set variables max_x = 8 max_y = 24 # Draw the grid for the graph graph_grid = [[" " for _ in range(max_y + 1)] for _ in range(max_x + 1)] # Draw the vertical line on the first column for col in range(max_y + 1): graph_grid[max_x][col] = "_" # Draw the horizontal line on the last row for row in range(max_x + 1): graph_grid[row][0] = "|" # Display the grid to the user for row in graph_grid: print("".join(row))