The Joy of Programming
Repeating Shapes
There is no preview available for this lesson. Please join the course to access it. Click here to enroll.
Questions
GS Gopika S Gopan
3 years ago
Post
Dismiss
Sir, don't we have to give 'return' command after 'def' function for drawing concentric circles?
Sir, don't we have to give 'return' command after 'def' function for drawing concentric circles?
A Ajmal.u
3 years ago
Post
Dismiss
... def concentric_squares(x, y, h, w, n): step1 = h/n step2 = w/n for i in range(n): s = rectangle(x=x, y=y, h=h, w=w) show (s) h = h - step1 w = w - step2 h, w = 200, 200 n = 10 # concentric squares at the center of the canvas concentric_squares(0, 0, h, w, n) # concentric squares at each corner concentric_squares(h/2, w/2, h/2, w/2, int(n/2)) concentric_squares(h/2, -w/2, h/2, w/2, int(n/2)) concentric_squares(-h/2, w/2, h/2, w/2, int(n/2)) concentric_squares(-h/2, -w/2, h/2, w/2,int(n/2)) ...
... def concentric_squares(x, y, h, w, n): step1 = h/n step2 = w/n for i in range(n): s = rectangle(x=x, y=y, h=h, w=w) show (s) h = h - step1 w = w - step2 h, w = 200, 200 n = 10 # concentric squares at the center of the canvas concentric_squares(0, 0, h, w, n) # concentric squares at each corner concentric_squares(h/2, w/2, h/2, w/2, int(n/2)) concentric_squares(h/2, -w/2, h/2, w/2, int(n/2)) concentric_squares(-h/2, w/2, h/2, w/2, int(n/2)) concentric_squares(-h/2, -w/2, h/2, w/2,int(n/2)) ...
A Ajmal.u
3 years ago
Post
Dismiss
how to post the source code in block format?
how to post the source code in block format?
Want to discuss?
Post it here, our mentors will help you out.
7.3 help
S Sreyas
3 years ago
Post
Dismiss
code for 7.3 and how to decrease w and h simultaneously
code for 7.3 and how to decrease w and h simultaneously
KM Khushiya M
3 years ago
Post
Dismiss
x, y = 0, 0 outer_length = 200 h, w = 200, 200 n = 10 step1 = h/n step2 = w/n l = step1 + step2 for i in range(n): s = rectangle (x=x, y=y, h=h, w=w) show (s) h = h - step1 w = w - step2
x, y = 0, 0 outer_length = 200 h, w = 200, 200 n = 10 step1 = h/n step2 = w/n l = step1 + step2 for i in range(n): s = rectangle (x=x, y=y, h=h, w=w) show (s) h = h - step1 w = w - step2
Want to discuss?
Post it here, our mentors will help you out.
THE ANSWER for 7.4
JE Joswin Emmanuel
3 years ago
Post
Dismiss
#ANSWER FOR 7.4 def co_sq(x,y,i): r=20 for i in range(i): show(rectangle(x,y,r,r)) r+=20 co_sq(0,0,10) co_sq(100,100,5) co_sq(-100,100,5) co_sq(-100,-100,5) co_sq(100,-100,5)
#ANSWER FOR 7.4 def co_sq(x,y,i): r=20 for i in range(i): show(rectangle(x,y,r,r)) r+=20 co_sq(0,0,10) co_sq(100,100,5) co_sq(-100,100,5) co_sq(-100,-100,5) co_sq(100,-100,5)
RT Rishikesh T P
3 years ago
Post
Dismiss
def rec(x,y,w,h,n): step1=w/n step2=h/n for i in range(n): s=rectangle(x=x,y=y,w=w,h=h) show(s) w=w-step1 h=h-step2 s1=rec(0,0,200,200,10) s2=rec(-100,100,75,75,5) s3=rec(100,-100,75,75,5) s4=rec(100,100,75,75,5) s5=rec(-100,-100,75,75,5) #I hope this is the answer
def rec(x,y,w,h,n): step1=w/n step2=h/n for i in range(n): s=rectangle(x=x,y=y,w=w,h=h) show(s) w=w-step1 h=h-step2 s1=rec(0,0,200,200,10) s2=rec(-100,100,75,75,5) s3=rec(100,-100,75,75,5) s4=rec(100,100,75,75,5) s5=rec(-100,-100,75,75,5) #I hope this is the answer
Want to discuss?
Post it here, our mentors will help you out.
THE ANSWER for 7.4
JE Joswin Emmanuel
3 years ago
Post
Dismiss
#ANSWER FOR 7.4 def co_sq(x,y,i): r=20 for i in range(i): show(rectangle(x,y,r,r)) r+=20 co_sq(0,0,10) co_sq(100,100,5) co_sq(-100,100,5) co_sq(-100,-100,5) co_sq(100,-100,5)
#ANSWER FOR 7.4 def co_sq(x,y,i): r=20 for i in range(i): show(rectangle(x,y,r,r)) r+=20 co_sq(0,0,10) co_sq(100,100,5) co_sq(-100,100,5) co_sq(-100,-100,5) co_sq(100,-100,5)
DP Dhanush P N
3 years ago
Post
Dismiss
##7.4 ```Python def concentric_squares(x, y, s, n): step = s/n for i in range(n): sq = rectangle(x=x, y=y, w=s, h=s) show(sq) s -= step w, h = 200, 200 s = 200 n = 10 concentric_squares(0, 0, s, n) concentric_squares(w/2, h/2, s/2, n//2) concentric_squares(w/2, -h/2, s/2, n//2) concentric_squares(-w/2, h/2, s/2, n//2) concentric_squares(-w/2, -h/2, s/2, n//2) ```
##7.4 ```Python def concentric_squares(x, y, s, n): step = s/n for i in range(n): sq = rectangle(x=x, y=y, w=s, h=s) show(sq) s -= step w, h = 200, 200 s = 200 n = 10 concentric_squares(0, 0, s, n) concentric_squares(w/2, h/2, s/2, n//2) concentric_squares(w/2, -h/2, s/2, n//2) concentric_squares(-w/2, h/2, s/2, n//2) concentric_squares(-w/2, -h/2, s/2, n//2) ```
A Ajmal.u
3 years ago
Post
Dismiss
def concentric_squares(x, y, h, w, n): step1 = h/n step2 = w/n for i in range(n): s = rectangle(x=x, y=y, h=h, w=w) show (s) h = h - step1 w = w - step2 h, w = 200, 200 n = 10 # concentricsqures at the center of the canvas concentric_squares(0, 0, h, w, n) # concentric squares at each corner concentric_squares(h/2, w/2, h/2, w/2, int(n/2)) concentric_squares(h/2, -w/2, h/2, w/2, int(n/2)) concentric_squares(-h/2, w/2, h/2, w/2, int(n/2)) concentric_squares(-h/2, -w/2, h/2, w/2,int(n/2))
def concentric_squares(x, y, h, w, n): step1 = h/n step2 = w/n for i in range(n): s = rectangle(x=x, y=y, h=h, w=w) show (s) h = h - step1 w = w - step2 h, w = 200, 200 n = 10 # concentricsqures at the center of the canvas concentric_squares(0, 0, h, w, n) # concentric squares at each corner concentric_squares(h/2, w/2, h/2, w/2, int(n/2)) concentric_squares(h/2, -w/2, h/2, w/2, int(n/2)) concentric_squares(-h/2, w/2, h/2, w/2, int(n/2)) concentric_squares(-h/2, -w/2, h/2, w/2,int(n/2))
Want to discuss?
Post it here, our mentors will help you out.