Name: Ang Li, Jash Rathod
Lab: Draw a Fibonacci Spiral
Date: Feb 22, 2018
Class: CS 111
This programe helps us draw the fibonacci spiral based on the input of number of layers from the user.
This function is to calculate the Fibonacci sequence.
n: is the numbers that will be in the Fibonacci sequence
The return values will be b who is the number is the Fibonacci sequence
for i in range(2,n+1):
a = a + b
a,b = b,a
return b #Returns the fibonacci vaue
def ss(n): #Drawing the squares and spirals
This function is to draw a square whose sides is the number inside Fibonacci sequence and
the arcs which will form the spiral.
n: is the number that will be the side of the squares and the radius of the arc in the
Tortoise: is the turtle who will draw the square.
for segment in range(4): #Loop index is defined as 4 for loop function for square
This is the main function to draw the Fibonacci spiral as it calls the other fucntions that calculates the fibonacci sequence and drawas the squares and arcs based on the calculations
n=int(input('How many layers: ')) #Asks user to input the number of layers
for i in range(n+1): #Loop index is defined as n+1 for loop function
ImportErrorTraceback (most recent call last)
7 This programe helps us draw the fibonacci spiral based on the input of number of layers from the user.
----> 9 import turtle
11 def fib(n):
/usr/lib/python2.7/lib-tk/turtle.py in ()
105 #print _ver
–> 107 import Tkinter as TK
108 import types
109 import math
/usr/lib/python2.7/lib-tk/Tkinter.py in ()
40 import _tkinter
41 except ImportError, msg:
—> 42 raise ImportError, str(msg) + ‘, please install the python-tk package’
43 tkinter = _tkinter # b/w compat for export
44 TclError = _tkinter.TclError
ImportError: No module named _tkinter, please install the python-tk package