[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
def solid_diamond(N):
for i in range(2*N+1):
for j in range(-N,N+1,1):
if abs(j) <= i and i <= N:
print('*', end="")
elif abs(j) <= N-i%(N+1)-1 and i > N:
print('*', end="")
else:
print(end=" ")
print()
def hollow_diamond(N):
for i in range(2*N+1):
for j in range(-N,N+1,1):
if abs(j) == i and i <= N:
print('*', end="")
elif abs(j) == N-i%(N+1)-1 and i > N:
print('*', end="")
else:
print(end=" ")
print()
def checkerboard(N):
for i in range(N):
for j in range(N):
if i%2 == 0:
if j%2 == 0:
print('*',end=' ')
else:
print('-',end=' ')
else:
if j%2 == 0:
print('-',end=' ')
else:
print('*',end=' ')
print()
def vee(N):
for i in range(N-1,-1,-1):
for j in range(N-1,-N,-1):
if i == abs(j):
print('*',end='')
else:
print(end=' ')
print()
def x(N):
for i in range(N-1,-N,-1):
for j in range(N-1,-N,-1):
if abs(i) == abs(j):
print('*',end='')
else:
print(end=' ')
print()
n=int(input('Enter N : '))
solid_diamond(n)
print()
hollow_diamond(n)
print()
checkerboard(n)
print()
vee(n)
print()
x(n)
print()
# "Nested squares" and "Nested right triangles" -> I dont understand the problem can you show me the diagram




[EC1-1] (patterns3.py) More fun with * patterns... Each of these is worth 0.25 points, except for...
Nested squares in python programming
(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 separated by at least one blank. That is, each is neither a djacent to the other on the same line nor in the same column: def nested squares (N)-> N-4, 2*N+1-9: three nested squares 立 立ựựự立 立立立立立 立立 立 立立立立立 立
(f) "Nested squares" with outer side length...
C++ any help is appreciated Program Pattern#2: Write a program that uses nested loop or for statements to display Pattern A below, followed by an empty line and then another set of loops that displays Pattern B. Once again no setw implementation is allowed here but you must use nested loop or for statements with proper indentation to generate these patterns. Use meaningful variable identifier names, good prompting messages and appropriate comments for each loop segment as well as other...
Using Python write a program that reads an int N >= 0, then prints out each of the following patterns of *. If you do NOT use the string repetition operator * in either problem, you will earn 0.25 points of Extra Credit for each. 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...
In Python Trace "Stars.py" by drawing a table that shows the values of relevant variables (row and star) and keeping track of the output. This program contains a nested for loop, so for each iteration of the outer loop, the inner loop executes in its entirety: row star 1 1 2 1 2 2 3 1 3 2 3 3 ... ... #******************************************************************** # stars.py # # Demonstrates the use of nested for loops. #******************************************************************** #----------------------------------------------------------------- # Prints a triangle...
E COMP 1224 Sec. 1 Spring 2017 Lab 1. I need the solution for
question 2 only please. Thank you
I need the solution for question 2 only please.
Thank you
COMP 1224 Sec. 1 Spring 2017 Lab 1 Your first lab will be similar to the examples discussed in class, covering programming hanction, and recursion. It includes the following tasks Using CdC write loop(s) to control and output a star pattern as follows: giving a integer N (use cin...
The program will need to accept two input arguments: the path of the input file and the path of the output file. See etc/cpp/example.ifstream.cpp for the basis of how to do this. Once the input and output file paths have been received, the program will need to open the input and output files, read and process each input file line and create a corresponding output file line, close the input and output files, and then create and output some summary...
this can be done in one class or two separate classes,in java
thanks!
You will implement and test several short recursive methods below. With the proper use of recursion, none of these methods should require more than a dozen lines of code. Test all these in the same class. Keep adding methods and testing until all are working 5. A Fractal Pattern Examine this pattern of stars and blanks, and write a recursive method that can generate patterns such as...
We are given a color picture consisting of an m?n array AŒ1::m;1::n? of pixels, where each pixel specifies a triple of red, green, and blue (RGB) intensities. Sup- pose that we wish to compress this picture slightly. Specifically, we wish to remove one pixel from each of the m rows, so that the whole picture becomes one pixel narrower. To avoid disturbing visual effects, however, we require that the pixels removed in two adjacent rows be in the same or...
This code is in Python: Fox Ciel starts to learn programming. The first task is drawing a fox! However, that turns out to be too hard for a beginner, so she decides to draw a snake instead. A snake is a pattern on a n by m table. Denote c-th cell of r-th row as (r, c). The tail of the snake is located at (1, 1), then it's body extends to (1, m), then goes down 2 rows to...
Can someone finish this class for me? There are comment instructions with what to do in the methods already. public class ArrayDemo { public void demonstrateTask1(){ System.out.println("Demonstrate Task 1"); int[] numbers = null; // note that numbers references nothing (null) initially ...