Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#1 2025-04-08 15:38:16

ktesla39
Member
From: Nepal
Registered: 2024-10-08
Posts: 165
Website

Py Graph

I wrote a python program to plot n number of coordinates or points in graph using Python Turtle:

import turtle
n = abs(int(input("Enter the number or points or vertices: ")))
if n > 25: print("Dont't joke! ")
else:
    x = [0]
    y = [0]
    for i in range(n):
        newx = int(input(f'Enter {i + 1} x coordinate: '))
        newy = int(input(f'Enter {i + 1} y coordinate: '))
        x.append(newx * 4)
        y.append(newy * 4)
        print()
    print(x)
    print(y)
    t = turtle.Turtle()
    t.color('blue')
    t.penup()
    t.goto(0,0)
    t.write('O')
    t.pendown()
    t.goto(0,250)
    t.write('Y')
    t.goto(0,-250)
    t.penup()
    t.forward(10)
    t.write("Y'")
    t.backward(10)
    t.pendown()
    t.goto(0,0)
    t.goto(250,0)
    t.write("X")
    t.goto(-250,0)
    t.write("X'")
    t.goto(0,0)
    t.penup()
    t.goto(x[1], y[1])
    for m in range(2, n+1):
        t.pendown()
        t.goto(x[m], y[m])
    t.goto(x[1], y[1])
   
Is this useful? smile


"Talent hits the target no one else can hit. Genius hits the target no one else can see." - Arthur Schopenhauer

Offline

Board footer

Powered by FluxBB