Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 7: Revisit the drunk pirate problem from the exercises in chapter 3. This time, the drunk pirate makes a turn, and then takes some

Exercise 7:

Revisit the drunk pirate problem from the exercises in chapter 3. This time, the drunk pirate makes a turn, and then takes some steps forward, and repeats this. Our social science student now records pairs of data: the angle of each turn, and the number of steps taken after the turn. Her experimental data is [(160, 20), (-43, 10), (270, 8), (-43, 12)]. Use a turtle to draw the path taken by our drunk friend.

Exercise from chapter 3: A drunk pirate makes a random turn and then takes 100 steps forward, makes another random turn, takes another 100 steps, turns another random amount, etc. A social science student records the angle of each turn before the next 100 steps are taken. Her experimental data is 160, -43, 270, -97, -43, 200, -940, 17, -86. (Positive angles are counter-clockwise.) Use a turtle to draw the path taken by our drunk friend. After the pirate is done walking, print the current heading.

The code i used for Exersice from chapter 3:

import turtle

wn = turtle.Screen() lovelace = turtle.Turtle()

lovelace.penup() lovelace.forward(60)

lovelace.pendown()

for angle in [160, -43, 270, -97, -43, 200, -940, 17, -86]:

lovelace.left(angle) lovelace.forward(100)

print("The pirate's final heading was", lovelace.heading())

Please, help me to write a code for exercise 7.

Programming language: Python

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions