Skip to content

Commit d93b080

Browse files
added more math features
1 parent 6c041fa commit d93b080

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

src/VisualScript.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import turtle
77
import matplotlib.pyplot as plt
88
import sys
9+
from statistics import *
910

1011
tur = turtle
1112

@@ -32,6 +33,8 @@ def process_code(file):
3233
"function":"def",
3334
"toLowerCase":"lower",
3435
"toUpperCase":"upper",
36+
"firstLetterUpper":"title",
37+
"skip":"pass"
3538

3639

3740

@@ -91,6 +94,7 @@ def artColor(color):
9194
return
9295
def artKey(function, key):
9396
tur.turtle.onkey(function, key)
97+
tur.turtle.listen()
9498
return
9599
def artStatic(feature):
96100
if feature == "stamp":
@@ -136,16 +140,32 @@ def logf(value, formatedvalue):
136140
def returnMedian(list, chart):
137141
sortedlist = sorted(list)
138142
middle_value = len(sortedlist) // 2
139-
final = (sortedlist[middle_value] + sortedlist[~middle_value]) / 2 # Use / for average
143+
final = (sortedlist[middle_value] + sortedlist[~middle_value]) / 2
140144
if chart.lower() == 'y':
141-
plt.plot(final, final)
145+
plt.scatter(final, final)
142146
plt.show()
143147
else:
144148
pass
145149
return final
146150
def exit():
147151
sys.exit()
148-
152+
def returnMode(list):
153+
sortedlist = sorted(list)
154+
avg = mode(sortedlist)
155+
return avg
156+
def returnMean(list):
157+
sortedlist = sorted(list)
158+
meannum = sum(sortedlist) / len(sortedlist)
159+
return meannum
160+
161+
162+
163+
164+
165+
166+
167+
168+
149169

150170

151171

src/example.vs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// this is a comment
22
list = [1, 2, 3, 4, 5, 6 , 7, 8, 9, 10, 10, 12, 11]
33
x = returnMedian(list, "y")
4-
log(x)
4+
log(x)
5+
function print():
6+
log("hello world")

0 commit comments

Comments
 (0)