Apr-22-2020, 01:27 AM
(This post was last modified: Apr-22-2020, 01:27 AM by rexyboy2121.)
Write a function that consumes a non-negative integer k and prints a k-size diamond. A k-size diamond consists of a top, a middle and a bottom. The middle is a single row of 2k+1 d’s. The top consists of k rows. The i throw in the top (starting from 0) contains 2i+1 d’s. The d’s on each top row are centred over the d’s on the middle row. A bottom is like a top but upside down.
Ex. k = 2;
d
ddd
ddddd
ddd
d
I have tried doing it in java, and want to do it in python. This is what I have so far in java:
int k;
int l;
void setup() {
size(400, 400);
k = 2;
textAlign(CENTER, CENTER);
String s = "d";
fill(255,0,0);
text(s + s + s + s +s, CENTER + 200, CENTER + 200);
}
Ex. k = 2;
d
ddd
ddddd
ddd
d
I have tried doing it in java, and want to do it in python. This is what I have so far in java:
int k;
int l;
void setup() {
size(400, 400);
k = 2;
textAlign(CENTER, CENTER);
String s = "d";
fill(255,0,0);
text(s + s + s + s +s, CENTER + 200, CENTER + 200);
}