1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Marrrta [24]
3 years ago
9

Complete the program below that takes in one positive, odd, integer, n (at least 3), and prints a "diamond" shape of stars with

the widest part of the diamond consisting of n stars. For example, if the input is n=5, the output would be:
*
***
*****
***
*
If the input is n=9, the output would be:
*
***
*****
*******
*********
*******
*****
***
*
The diamond shape has rows of stars (asterisks) with and odd number of stars on each row. In the n=9 example, the rows had 1 star, 3 stars, 5 stars, 7 stars, 9 stars, 7 stars, 5 stars, 3 stars, and 1 star. Additionally, the rows with less than n stars have leading spaces to "center" the row (so that the center star of each row is directly above/below the center star of the other rows). Spaces are important in this assignment. Assume there are no trailing spaces (spaces at the end of each row). Because n must be odd and each row will have an odd number of stars, every row will have a "center" star.
Computers and Technology
1 answer:
avanturin [10]3 years ago
5 0

Answer:

n = int(input("Enter the n (positive odd integer): "))

for i in range(1, n+1, 2):

   print(i*"*")

for i in range(n-2, 0, -2):

   print(i*"*")

Explanation:

*The code is in Python.

Ask the user to enter the n

Create a for loop that iterates from 1 to n, incrementing by 2 in each iteration. Print the corresponding number of asterisks in each iteration

Create another for loop that iterates from n-2 to 1, decrementing by 2 in each iteration. Print the corresponding number of asterisks in each iteration

You might be interested in
he superclass Student contains: a constructor that accepts a String corresponding to the name of the school the student attends
natita [175]

Solution :

public $\text{class}$ Student {

$\text{protected String}$ school$;$

public $\text{Student}$(String school) {

$\text{this.school}$ = school;

}

public String $\text{toString}()$ {

return $\text{"student at"}$ + school;

}

}

HighSchool$\text{Student.java}$ :

public class $\text{HighSchoolStudent}$ extends Student {

public $\text{HighSchoolStudent}$(String school) {

super$\text{(school)}$;

}

public String $\text{toString}()$ {

return $\text{"high school"}$ + super.$\text{toString}()$;

}

}

3 0
2 years ago
Anyone trying to play fortnite ? im bored lol
kkurt [141]

Answer:

what arena division r u in

and nr

Explanation:

7 0
2 years ago
Read 2 more answers
adding ______around calculations indicates which calculations should be performed first before following the typical order of op
Wittaler [7]
Parentheses! Hope this helped you
5 0
3 years ago
2 Manter o autocontrole nos ajuda a evitar muitos problemas na nossa vida pessoal e no ambiente profissional. Em se tratando de
Umnica [9.8K]

Answer:

english please

Explanation:

8 0
3 years ago
When planning your website, what is one of the key things you should consider
Alex_Xolod [135]

You should definitely consider what kind of audience you are appealing to. For example, if you were running a business based on cosmetic products you may want to focus your website on self-care and makeup tips rather than something like cooking. By making your website direct about what you offer, the better the audience will understand. This will make your website succeed. Hope this helped :))

4 0
2 years ago
Read 2 more answers
Other questions:
  • You just came back to your office from a meeting about is security.​ you've learned a few things about a​ "good" password, and y
    15·1 answer
  • What is the output of the following program? #include using namespace std; class TestClass { private: int val; void showVal() {
    5·1 answer
  • A user calls the help line and ask for some help installing a new keyboard. He isn't sure how to plug the keyboard into the comp
    15·1 answer
  • In Alphatech Systems, email software screens incoming messages by organizing them into mailboxes and identifying junk mail. As a
    13·1 answer
  • You wrote a C application that takes 20 seconds using your desktop processor. An improved C compiler is released that requires o
    6·1 answer
  • What effect does the interconnectedness of modern media have on society?
    14·2 answers
  • Which ORDER BY clause causes 10 rows to be retrieved from the result set, starting with the 20th row?
    5·1 answer
  • For C++ ONLY please,
    14·1 answer
  • Who is your favorite person from squid game?
    13·2 answers
  • What is the "Driver's Compact Law"?
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!