Write a turtle graphics python program repeat_squares.py that uses nested loops to draw 100 squares, to create this design:
Turtle-squares.png
starting with the smallest square in the bottom right-hand corner.
Start at position (-4,4). At each step increase the length of each side by 4 pixels. Draw 100 squares. Please submit with an animation speed of 0 and the turtle hidden
turtle.hideturtle()
The required program is given below in case of any doubts you can ask me in comments,also please do upvote as i need it really.
################################################################
UPDATED CODE
main.py
import turtle
def square(skk,size):
for i in range(4):
skk.forward(size)
skk.left(90)
def main():
TURTLE_SIZE = 20
screen = turtle.Screen()
skk = turtle.Turtle()
skk.penup()
skk.goto(screen.window_width()/2 - TURTLE_SIZE/2, TURTLE_SIZE/2
-screen.window_height()/2)
skk.pendown()
skk.showturtle()
SizeVar = 4
numberOfSquares = 100
#tostar t at position -4,4
#skk.goto(-4,4)
skk.speed(0)
skk.penup()
skk.pendown()
skk.left(90)
skk.hideturtle()
for i in range(numberOfSquares):
square(skk,SizeVar)
SizeVar += 4
turtle.done()
if __name__ == "__main__":
main()
######################################################################
main.py
import turtle
def square(skk,size):
for i in range(4):
skk.forward(size)
skk.left(90)
def main():
skk = turtle.Turtle()
SizeVar = 4
numberOfSquares = 100
skk.speed(0)
skk.penup()
skk.goto(-4,4)
skk.pendown()
skk.left(90)
skk.hideturtle()
for i in range(numberOfSquares):
square(skk,SizeVar)
SizeVar += 4
turtle.done()
if __name__ == "__main__":
main()
vaibhav.py - C:/Users/dpa_kirtibajaj/vaibhav.py (3.7.4) File Edit Format Run Options Window Help import turtle def square iskk, size): for i in range (4): skk.forward(size) skk. left (90) def main(): skk = turtle. Turtle() SizeVar = 4 number of Squares = 100 skk. speed (0) skk. penup () skk.goto (-4,4) skk. pendoun() skk. left (90) skk.hideturtle() for i in range (number of Squares): square (skk, SizeVar) SizeVar += 4 turtle.done() if heme__ == "__main_": main()
||||||||
Turtle Graphics with nested loop: Write a turtle graphics python program repeat_squares.py that uses nested loops...
Python Question Task 4 Create a function named poker_table that uses Turtle Graphics to create a single poker table to accommodate all players. There should be four parameters: num_players indicates the number of players; side_length indicates the length in pixels of each side of the table; and x and y, which give the location where you should start drawing the table. The poker table should be a simple regular polygon (that is, with sides of equal length). The number of...
Write them in python IDLE ***** 5. Average Rainfall Write a program that uses nested loops to collect data and calculate the average rainfall over a period of years. The program should first ask for the number of years. The outer loop will iterate once for each year. The inner loop will iterate twelve times, once for each month. Each iteration of the inner loop will ask the user for the inches of rainfall for that month. After all iterations,...
Use Python 3 Create a program that uses Turtle to draw shapes. Show the following menu: Enter Circle Enter Rectangle Remove Shape Draw Shapes Exit Circles – User inputs position, radius, and color. The position is the CENTER of the circle Rectangles – User inputs position, height, width, color. The position is the lower left-hand corner Colors – Allow red, yellow, blue, and green only Remove – Show the number of items in the list and let the user enter...
In this assignment, you will write a program in C++ which uses files and nested loops to create a file from the quiz grades entered by the user, then reads the grades from the file and calculates each student’s average grade and the average quiz grade for the class. Each student takes 6 quizzes (unknown number of students). Use a nested loop to write each student’s quiz grades to a file. Then read the data from the file in order...
Using python, create a program using nested loops to write a function called substring(s,b) that returns True or False depending on whether or not b is a substring of s. For example: String: "Diamond" Substring: "mond" The code will then state that this is true and "mond" is a substring of "Diamond". Example of what the program should output: Enter string: Tree Enter substring: Tre Yes, 'Tre' is a substring of 'Tree' Limitation: This program cannot use "find()" and "in"...
Design and implement a single program: • to produce a simple graphical representation of a set of regular pentagons, as shown in Figure 1 (below). The output should consist of 4 pentagons with sides of length 20, 40, 60 and 80 respectively, nested as shown. A regular pentagon has 5 sides and the inner angle of a regular pentagon is 72 degrees. The distance between any two successive pentagons should be the same: there should be 10 units (measured as...
Python 2. (10 pts) Write the definition of a function, sqr_10(t), which uses turtle, t, to draw a square each side of which is 10 long.
Write a program called draw_shapes.py. In your program, Create a block header with: your name the date a short description of what the program does: Assignment 5: Draw shapes using turtle Import the turtle module. Create a window and screen (canvas) where your turtle will draw. Make the window 400 pixels wide x 400 pixels high and give it an indigo background and a title of "Shapes". Use this code to create a window object: # a place for the...
I need help with turtle graphics assignment in python 3, please! Write a program named Lastname_firstname_clock.py to display a clock face with hands showing the current time. The radius of the clock face (the distance from the center to the hour markers) is 150. The hour hand has length 100, and the minute hand has a length of 120 You may design the clock in one of three ways: using the square cursor shape (hint: stamp)) for the hour markers...
Lab #6 Number Guessing Game – Loops and Nested Loops Requirements: Design, develop, test, and submit a program for a Number Guessing game. The program will select a random number between 0 and 100, allow the user to try up to 10 times to guess the number, and tell the user if each guess is too high, too low, or correct. The actual game portion must be a function...you can use more than one function in your program. The amount...