import turtle
from math import *
def formulaX(R, r, p, t):
x = (R-r)*cos(t) - (r+p)*cos((R-r)/r*t)
def formulaY(R, r, p, t):
y = (R-r)*sin(t) - (r+p)*sin((R-r)/r*t)
def t_iterating(R, r, p):
t = 0
turtle.down()
while t < 20*pi:
t = t+0.01
turtle.goto(formulaX(R, r, p, t), formulaY(R, r, p, t))
turtle.up()
def main():
R = int(input("The radius of the fixed circle: "))
r = int(input("The radius of the moving circle: "))
p = int(input("The offset of the pen point, between : "))
if p < 10 or p > 100:
input("Incorrect value for p!")
t_iterating(R, r, p)
input("Hit enter to close...")
main()
По какой-то причине я постоянно получаю следующую ошибку:
Traceback (most recent call last):
File "/Users/liammitchell/Desktop/Comp Sci/Spirograph/spirograph.py", line 34, in
main()
File "/Users/liammitchell/Desktop/Comp Sci/Spirograph/spirograph.py", line 30, in main
t_iterating(R, r, p)
File "/Users/liammitchell/Desktop/Comp Sci/Spirograph/spirograph.py", line 18, in t_iterating
turtle.goto(formulaX(R, r, p, t), formulaY(R, r, p, t))
File "", line 1, in goto
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/turtle.py", line 1774, in goto
self._goto(Vec2D(*x))
TypeError: type object argument after * must be a sequence, not NoneType
Я пытаюсь написать код для спирографа, используя черепаху Python, но постоянно получаю странную ошибку.
Вот мой код:
[code]import turtle from math import *
def formulaX(R, r, p, t): x = (R-r)*cos(t) - (r+p)*cos((R-r)/r*t)
def formulaY(R, r, p, t): y = (R-r)*sin(t) - (r+p)*sin((R-r)/r*t)
def t_iterating(R, r, p): t = 0 turtle.down()
while t < 20*pi: t = t+0.01 turtle.goto(formulaX(R, r, p, t), formulaY(R, r, p, t)) turtle.up()
def main(): R = int(input("The radius of the fixed circle: ")) r = int(input("The radius of the moving circle: ")) p = int(input("The offset of the pen point, between : "))
if p < 10 or p > 100: input("Incorrect value for p!")
t_iterating(R, r, p)
input("Hit enter to close...")
main() [/code]
По какой-то причине я постоянно получаю следующую ошибку:
[code]Traceback (most recent call last): File "/Users/liammitchell/Desktop/Comp Sci/Spirograph/spirograph.py", line 34, in main() File "/Users/liammitchell/Desktop/Comp Sci/Spirograph/spirograph.py", line 30, in main t_iterating(R, r, p) File "/Users/liammitchell/Desktop/Comp Sci/Spirograph/spirograph.py", line 18, in t_iterating turtle.goto(formulaX(R, r, p, t), formulaY(R, r, p, t)) File "", line 1, in goto File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/turtle.py", line 1774, in goto self._goto(Vec2D(*x)) TypeError: type object argument after * must be a sequence, not NoneType [/code]