Untitled

mail@pastecode.io avatar
unknown
python
a year ago
972 B
5
Indexable
Never
import tkinter as tk


root = tk.Tk()

mycanvas = tk.Canvas(root, width=400, height=320,bg="white")
mycanvas.pack()

for i in range(13):
    mycanvas.create_line(80, 20+i*20, 360, 20+i*20,fill="black")

for i in range(0,16,2):
    mycanvas.create_line(80+i*20,20, 80+i*20,260,fill="black")

cnt=0
for i in range(255,0,-39):
    mycanvas.create_text(60, i, text=cnt,fill='black',font=('Arial', 18))   
    cnt+=1000
cnt=0
for i in range(80,400,40):
    mycanvas.create_text(i, 280, text=cnt,fill='black',font=('Arial', 18))   
    cnt+=1

mycanvas.create_text(20, 140, text='f(n)',fill='black',font=('Arial', 22))
mycanvas.create_text(220, 300, text='n',fill='black',font=('Arial', 22))

ans=[0]*10
cur=1
for i in range(1,10):
    cur*=i
    ans[i]=ans[i-1]+cur

y=[0]*10
for i in range(8):
    y[i]=260-ans[i]*0.04

x=[0]*10
x[0]=80
for i in range(1,8):
    x[i]=x[i-1]+40

for i in range(7):
    mycanvas.create_line(x[i],y[i],x[i+1],y[i+1],fill="red")

root.mainloop()