Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
please fix this code the turtle suppose to start from center but my code start from side which is wrong please fix it.
please do it in python language and my code is also in python. please include the out put of the snip it.
thanks
code:
import turtle
import random
def draw_bounds(size, center=(0,0)):
turtle.penup()
turtle.goto(center)
turtle.setheading(0)
turtle.pendown()
turtle.forward(size/2)
turtle.left(90)
turtle.forward(size/2)
turtle.left(90)
turtle.forward(size)
turtle.left(90)
turtle.forward(size)
turtle.left(90)
turtle.forward(size)
turtle.left(90)
turtle.forward(size/2)
turtle.left(90)
turtle.forward(size/2)
turtle.penup()
turtle.goto(center)
turtle.pendown()
def step(step_size=20):
directions = ['north', 'south', 'east', 'west']
direction = random.choice(directions)
if direction == 'north':
turtle.setheading(90)
turtle.forward(step_size)
elif direction == 'south':
turtle.setheading(270)
turtle.forward(step_size)
elif direction == 'east':
turtle.setheading(0)
turtle.forward(step_size)
elif direction == 'west':
turtle.setheading(180)
turtle.forward(step_size)
def walk(limits =(-200, 200)):
steps = 0
while True:
x, y = turtle.position()
if abs(x) >= limits[1] or abs(y) >= limits[1]:
break
step()
steps += 1
return steps
turtle.speed('fastest')
turtle.hideturtle()
draw_bounds(400)
turtle.showturtle()
steps = walk((0, 200))
turtle.write("Number of Steps: {}".format(steps), font=("Arial", 14, "bold"), align="center")
turtle.done()
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Can you fix the error in the python code. import numpy as npimport matplotlib.pyplot as plt N = 20 # number of points to discretizeL = 0.15X = np.linspace(0, L, N) # position along the rodh = L / (N - 1) # discretization spacing C0t = 0.200 # concentration at x = 0Cth = 0.00000409D = 0.0000025t_avg = 0n = 0 tfinal = 300Ntsteps = 1000dt = tfinal / (Ntsteps - 1)t = np.linspace(0, tfinal, Ntsteps) alpha =( D * dt / h**2) C_xt = [] # container for all the time steps # initial condition at t = 0C = np.zeros(X.shape)C[0] = C0t C_xt += [C] for j in range(1, Ntsteps): N = np.zeros(C.shape) N[0] = C0t N[1:-1] = alpha*C[2:] + (1 - 2 * alpha) * C[1:-1] + alpha * C[0:-2] N[-1] = N[-2] # derivative boundary condition flux = 0 C[:] = N C_xt += [N] if ((Cth-0.000001) < N[-1]<(Cth+0.000001)): print ('Time=',t[j],'conc=',[N[-1]],'Cthr=',[Cth]) t_avg = t_avg+t[j] n = n + 1 # plot selective solutions if j in…arrow_forwardCreate another class TestCarwhich creates array of n number of cars, uses appropriate set methods to set the values of parametersof every car. Display the details of each car. (If max speed is between 120 and 150 then category is“High speed” otherwise “Normal”) (JAVA)arrow_forwardputty program for unix can can not get the screen to show the mountain list. how do i do this?arrow_forward
- Create an ArrayList of strings to store the names of celebrities or athletes. Add five names to the list. Process the list with a for loop and the get() method to display the names, one name per line. Pass the list to a void method. Inside the method, Insert another name at index 2 and remove the name at index 4. Use a foreach loop to display the arraylist again, all names on one line separated by asterisks. After the method call in main, create an iterator for the arraylist and use it to display the list one more time.arrow_forwardImplement a “To Do” list. Tasks have a priority between 1 and 9, and a description (which you can come up with on your own, say, “wash dishes”). The program is going to prompt the user to enter the tasks by running the method add_priority_description, the program adds a new task and prints the current list with priority 1 tasks on the top, and priority 9 tasks at the bottom. The program will continue to ask the user if they want to add another tasks, and repeat the add_priority_description method, or enters Q to run the quit method to quit the program. Sample output (not limited to) 1. Study for the final 1. Take the final 2. Watch Justice League with friends 3. Play ball 9. Wash Dishes 9. Clean room. There is a possibility of two tasks having the same priority. If so, the last task that was entered gets to be printed first. Use HEAP in your solution.arrow_forwardImplement the "Add player" menu option. Prompt the user for a new player's jersey number and rating. Append the values to the two vectors. Ex: Enter a new player's jersey number: 49 Enter the player's rating: 8arrow_forward
- for the class ArrayAverage write a code that calculates the average of the listed numbers with a double result for the class ArrayAverageTester write a for each loop and print out the resultarrow_forwardComplete the recursive drawBoxes() method so that it will draw all of the boxes in the image below. It currently only draws the first and smallest Box. Feel free to use a different shape if you do not like boxes.arrow_forwardThis is needed in Java Given an existing ArrayList named friendList, find the first index of a friend named Sasha and store it in a new variable named index.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education