Write My Paper Button

WhatsApp Widget

[EC1-1] (patterns3.py) More fun with * patterns… Each of these is worth 0.25 points, except for…

Homework Help Question & Answers

[EC1-1] (patterns3.py) More fun with * patterns… Each of these is worth 0.25 points, except for…

[EC1-1] (patterns3.py) More fun with * patterns… Each of these is worth 0.25 points, except for (f) and (g), which are worth 1 point each.

Write a program that reads an int N >= 0, then prints out each of the following patterns of *. Here, you may use the * repetition operator, if you wish. Also, each pattern must be output via a single function call to the given named function with single parameter N. Examples for N==4 follow, with explanations of how the displayed diagram reflects this value of N:

(a) def solid_diamond(N) => 2*N+1 lines, first with 1 star, second with 3 stars, …, N+1 line with 2*N+1 stars, then subsequent lines repeating the pattern, reversed; each line’s stars are centered between first and Nth columns:

(b) def hollow_diamond(N) => same as above, but with no interior stars (no 2 stars adjacent on same line):

(c) def checkerboard(N) => “Checkerboard” of * and of side N: first row starts with *, then alternates and d. Second row starts with , then alternates * and -. Thus, adjacent lines start with alternating symbols.

(d) def vee(N) => “V” with N rows:

(e) def x(N) => “X” with 2*N-1 rows:

(f) “Nested squares” with outer side length of 2*N+1 and each inner square spaced as shown. Note that any two *’s, each from a different square, are neither adjacent on the same line nor in the same column:

def nested_squares(N)=> N==4, 2*N+1 == 9: three nested squares

(g) “Nested right triangles” with outer legs each having 2*N+1 *’s and each inner triangle spaced as shown. As in the previous problem, note that any two *’s, each from a different triangle, are neither adjacent on the same line or in the same column on adjacent lines:

def nested_triangles(N)=> N==4, 2*N+1 == 9: two triangles

N==6, 2*N+1 == 13: three triangles

0 0
Add a comment
Don`t copy text!
WeCreativez WhatsApp Support
Our customer support team is here to answer your questions. Ask us anything!
???? Hi, how can I help?