This repository was archived by the owner on May 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathCirclePyramid2.0.py
More file actions
58 lines (48 loc) · 1.43 KB
/
CirclePyramid2.0.py
File metadata and controls
58 lines (48 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""
# This code will ask the user how many blocks they want on the bottom of the pyramid
# and then draw a pyramid of squares, subtracting one block from each row.
"""
'''
# This function moves to next row with x-value based on how many blocks are to
# be placed and the y-value based on the row number (gets 50 pixels higher each row)
'''
#This function moves to the next row up
def move_to_row(num_blocks):
x_value = -(((num_blocks*50)/2)-o)
y_value = -200+(50*row_value)
penup()
setposition(x_value,y_value)
pendown()
# This function draw a row of blocks based on user value
def draw_block_row(num_blocks):
for i in range(num_blocks):
circle(radius)
penup()
forward(50)
pendown()
# Set row value to 0
speed(5)
#Current row and offset defined
row_value = 0
o = 25
#moving to the starting position
penup()
forward(25)
pendown()
#radius defined
radius = 25
# Ask the user how many blocks should be on bottom row
num_blocks=int(input("How many blocks on the bottom row? (8 or less): "))
'''
# Call function to move Tracy to beginning of row position and then increase row
# variable value. Then Tracy will draw the row of blocks needed and subtract one
# from the num blocks variable.
'''
#===========================
# MAIN
#===========================
for i in range(num_blocks):
move_to_row(num_blocks)
row_value=row_value+1
draw_block_row(num_blocks)
num_blocks=num_blocks-1