-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
110 lines (103 loc) · 2.37 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
from functions import *
from turtle import *
from math import *
k=0
print("=============================================")
print(" 그래프 그리기 프로그램 v4.0 - 19152 임지안 ")
print("=============================================")
while True:
print("그리고 싶은 함수의 종류를 아래와 같이 입력해주세요.")
func = input("다항함수: 1, 무리함수: 2, 유리함수: 3")
try:
if int(func) < 4 and int(func) > 0:
break
except:
break
if func == '1':
A = polynomial(0,[])
tier = A[0]
arr = A[1]
def ef(x):
global tier
global arr
k = tier
result = 0
while k >= 0:
a = x**k
result += a * float(arr[k])
k -= 1
return result
elif func == '2':
B = irrational(0,0,0,0)
def ef(x):
return B[0] * sqrt(B[1]*x + B[2]) + B[3]
elif func == '3':
C = rational(0,0,0,0)
def ef(x):
global k
try:
k = -1*C[3]/C[2]
a = ((C[0]*x + C[1])/(C[2]*x+C[3]))
except:
a = 9999999999
return a
title("만능 그래프 그리기 v2.0")
setup(width = 900,height = 900)
speed(0)
for i in (90,180,270,360):
fd(450)
goto(0,0)
setheading(i)
goto(0,0)
pencolor('red')
penup()
if func == '1':
goto(200,0)
write("200")
goto(0,200)
write("200")
goto(-200,0)
write("-200")
goto(0,-200)
write("-200")
goto(-900,ef(-900))
pendown()
for i in range(-900,900):
goto(i,ef(i))
elif func == '2':
goto(200,0)
write("200")
goto(0,200)
write("200")
goto(-200,0)
write("-200")
goto(0,-200)
write("-200")
for i in range(-900,900):
try:
goto(i,ef(i))
pendown()
except:
continue
elif func == '3':
goto(225,0)
write("5")
goto(0,225)
write("5")
goto(-225,0)
write("-5")
goto(0,-225)
write("-5")
for i in range(-900,900):
try:
speed(5)
if abs(ef(i/45)) >= 20:
penup()
continue
else:
goto(i,45*ef(i/45))
pendown()
except:
penup()
speed(0)
continue