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
What science category includes physics and biology?
enyata [817]

Answer:

Physical science is the study of the inorganic world. That is, it does not study living things. (Those are studied in biological, or life, science.) The four main branches of physical science are astronomy, physics, chemistry, and the Earth sciences, which include meteorology and geology.

5 0
2 years ago
Which description of the plain text file format is most accurate?
Sedbober [7]

Answer:

uses binary code to store data!

Explanation:

5 0
3 years ago
Go to the Creamy Ice Corporation passage on the next page. Insert the trademark sign after the word “Corporation'' in the first
GuDViN [60]

Answer:

v

Explanation:

because it is

5 0
3 years ago
When is it not necessary to invoke the method myMethod using dot notation? When myMethod is private. When myMethod is invoked by
Paraphin [41]

Answer:

When myMethod is invoked by a method in the same class as myMethod.

Explanation:

When you are in a class, it is like a different enviroment and within that class you can call a method without using the dot notation because you are still within the class.

Outside the class and despite the type of method, public, private or static, the dot notation will be required.

5 0
2 years ago
Read 2 more answers
1. Comments can be placed anywhere in Python, including in the middle of a line of code.
viva [34]

Answer:

This is true

Explanation:

Comments don't effect your program at all.

The computer doesn't even read the line with the comment, what you right before the comment tells the computer to skip this line.

So you can place them anywhere

6 0
3 years ago
Other questions:
  • An employee is angry with his boss and wants to sabotage the company. To accomplish this he secretly changes some of the values
    7·1 answer
  • Which device lets you hear audio on your computer?
    12·2 answers
  • AddAll - Adds all the doubles in the string with each other. Note every double is separated by a semi-colon. AddAll("1.245;2.9")
    6·1 answer
  • Google Glass uses a projector that bounces a beam of light off a prism and projects the image directly on your ________. field o
    14·1 answer
  • Client/server awareness. Visit three local stores in your neighborhood or mall and notice the information technology in the stor
    9·2 answers
  • How can i address inv file in c for open it?
    13·1 answer
  • Define the terms of data and information .​
    6·1 answer
  • What do you hope will be in/added GTA 6?
    13·1 answer
  • Answer if you know Javascript, html, css, python, and Ruby.
    12·1 answer
  • In how many positions are there nucleotide differences between your query sequence and the sequence of accession AY259214.1
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!