<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Book Exercises
Spins with compass
Step1:  Fun with Turtles
Step2:  Looking at documentation for tutles
The documentation for the module inside of Python can be found here
Step3:  Using Range
Step4:  Lots of turtles
Step5:  Math
Step6:  Random
Remember how it's not actually random. Here is an example
Step7:  Chapter 4 Exercises
Bottles of beer
Step8:  Cool sample by
<ASSISTANT_TASK:>
Python Code:
spins = input("How many times did you spin? (Enter a negative number for couter-clockwise spins) ")
# Need to ensure the direction of the spin is always correct.
# This works because of the definition of the modulo operator and what happens with
# negative numbers.   Keep this in mind for the assignment for chapter 3.
degrees = (float(spins) * 360) % 360
print("You are facing", degrees, "degrees relative to north")
Explanation: Book Exercises
Spins with compass
End of explanation
import turtle               
wn = turtle.Screen()        # creates a graphics window
alex = turtle.Turtle()      # create a turtle named alex
alex.speed(1)
alex.shape('turtle')
for i in [0,1,2,3,4,5]:
    alex.forward(150)           # tell alex to move forward by 150 units
    alex.left(85)               # turn by 90 degrees
    alex.forward(75)
## This won't run as expected with the notebook. Wait a moment for the window to be created.
wn.exitonclick()
Explanation: Fun with Turtles
End of explanation
# Copied from the documentation example. This is bad practice to do import * DO NOT DO IT!
from turtle import *
color('red', 'yellow')
begin_fill()
while True:
    forward(200)
    left(170)
    if abs(pos()) < 1:
        break
end_fill()
done()
Explanation: Looking at documentation for tutles
The documentation for the module inside of Python can be found here:
https://docs.python.org/3.6/library/turtle.html
End of explanation
for number in range(6, 0, -1):
    print("I have", number, "cookies.  Iím going to eat one.")
print('I ate all my cookies')
Explanation: Using Range
End of explanation
import turtle
wn = turtle.Screen()
wn.bgcolor("lightgreen")
tess = turtle.Turtle()
tess.color("blue")
tess.shape("turtle")
jim = turtle.Turtle()
jim.color("green")
jim.shape("turtle")
carl = turtle.Turtle()
carl.color("red")
carl.shape("turtle")
tess.up()
carl.up()
jim.up()
# Keep in mind for today's studio
for size in range(5, 60, 2):    # start with size = 5 and grow by 2
    tess.stamp()                # leave an impression on the canvas
    carl.stamp()
    jim.stamp()
    
    carl.forward(size + 10)
    jim.forward(size)
    tess.forward(size)          # move tess along
    
    carl.right(90)
    jim.left(24)
    tess.right(24)              # and turn her
wn.exitonclick()
Explanation: Lots of turtles
End of explanation
from math import sqrt
print(sqrt(24))
print(sqrt(25))
print(sqrt(-2))
Explanation: Math
End of explanation
import random
random.seed(5)
print(random.randint(0,10))
print(random.randint(0,10))
print(random.randint(0,10), '\n')
random.seed(5)
print(random.randint(0,10))
print(random.randint(0,10))
print(random.randint(0,10), '\n')
random.seed(5)
print(random.randint(0,10))
print(random.randint(0,10))
print(random.randint(0,10), '\n')
random.seed(5)
print(random.randint(0,10))
print(random.randint(0,10))
print(random.randint(0,10), '\n')
Explanation: Random
Remember how it's not actually random. Here is an example:
End of explanation
bottles_of_beer = 99
for bottle_number in range(bottles_of_beer, 0, -1):
    print(bottle_number, "Bottles of Beer on the Wall")
    print("Take one down pass it around")
Explanation: Chapter 4 Exercises
Bottles of beer
End of explanation
import turtle
import random
wn = turtle.Screen()
anaise = turtle.Turtle()
hour = 1
lines = 1
angle = 1
anaise.speed(0)
# Set the color mode so the mac is happy.
# wn.colormode(255)
#change starting point of line randomly
while lines < 200:
    anaise.goto(random.randrange(50), random.randrange(50))
    anaise.down()
    angle = (random.randrange(360))
    anaise.color(random.randrange(255),random.randrange(255),random.randrange(255))
    anaise.pensize(random.randrange(11))
    anaise.right(angle)
    anaise.forward(random.randrange(100))
    anaise.up()
    
    #Count the number of times the loop occurs
    lines = lines + 1
    
wn.exitonclick()
Explanation: Cool sample by: Murial
End of explanation
<END_TASK>