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
aliya0001 [1]
3 years ago
15

This program outputs a downwards facing arrow composed of a rectangle and a right triangle. The arrow dimensions are defined by

user specified arrow base height, arrow base width, and arrow head width.
(1) Modify the given program to use a loop to output an arrow base of height arrow_base_height.
(2) Modify the given program to use a loop to output an arrow base of width arrow_base_width.
(3) Modify the given program to use a loop to output an arrow head of width arrow_head_width.
(4) Modify the given program to only accept an arrow head width that is larger than the arrow base width.
Use a loop to continue prompting the user for an arrow head width until the value is larger than the arrow base width.
while arrow_head_width <= arrow_base_width: arrow_head_width = int(input('Enter arrow head width:\n')) Example output for arrow_base_height = 5, arrow_base_width = 2, and arrow_head_width = 4: Enter arrow base height: 5 Enter arrow base width: 2 Enter arrow head width: 4 tot tr

Computers and Technology
1 answer:
skad [1K]3 years ago
5 0

Answer:

Here is the Python program:

arrow_base_height = int(input('Enter arrow base height: \n'))  #prompts user to enter the arrow base height

arrow_base_width = int(input('Enter arrow base width: \n')) #prompts user to enter the arrow base width

arrow_head_width = int(input('Enter arrow head width: \n'))  #prompts user to enter the arrow head width

while (arrow_head_width <= arrow_base_width):  #ensures that the arrow head width is greater than base width

    arrow_head_width = int(input('Enter arrow head width: \n'))  #keeps prompting user to enter arrow head width until the value is larger than the arrow base width.

for i in range(arrow_base_height):  #to print arrow shaft

   for j in range(arrow_base_width):  #iterates through arrow base width

       print ('*', end='')  #prints asterisks

   print ()  #prints new line

for i in range(arrow_head_width):  #iterates through arrow head width arrow head

   for j in range(arrow_head_width-i):  #iterates through arrow head width-i

        print ('*', end='')  #prints asterisks

   print()  #prints new line

       

Explanation:    

The program works as follows:

Suppose user enters 5 as arrow base height, 2 as arrow base width and 4 as arrow head widths so,

arrow_base_height = 5

arrow_base_width = 2

arrow_head_width = 4

Since the arrow_head_width is not less than arrow_base_width so the while loop at the start does not execute. Program control moves to the statement:

for i in range(arrow_base_height):

for j in range(arrow_base_width):

Both of these loop are used to print the shaft line and after execution of these loops the output becomes:

**

**

**

**

**

Note that the outer loop is executed 5 times as arrow_base_height=5 and the inner loop iterates two times for each iteration of outer loop because arrow_base_width is 2 and the print ('*', end='') statement keeps printing the asterisks whereas print() prints a new line after printing 2 asterisks at each line.

Next the program moves to the following loops:

for i in range(arrow_head_width):

   for j in range(arrow_head_width-i):

Both of these loop are used to print the arrow head and after execution of these loops the output becomes:

****

***

**

*

Note that the outer loop is executed 4 times as arrow_head_width=4 and the inner loop iterates 4 times in start and decrements one time at each iteration and the print ('*', end='') statement keeps printing the asterisks whereas print() prints a new line after printing 2 asterisks at each line.

So the entire output of this program is:

**

**

**

**

**

****

***

**

*

The screenshot of the program along with its output is attached.

You might be interested in
How does the use of imagery create meaning
Contact [7]

Imagery is a feature of written and spoken language and occurs whenever someone has chosen to use language in a non-literal way.

Imagery is a way of describing something symbolically, using words to create a picture in the reader's imagination.

In the Close Reading paper you need to be able to recognise imagery and to consider how successful the imagery is at conveying to you what the writer is trying to express. Imagery frequently conveys more than just meaning. It is used to heighten the effect of language and is often an extension of word-choice. Normally an image will extend to a phrase or a few words but sometimes it will be longer. The simplest form of imagery to recognise is when something or someone is compared to something else, with the purpose of establishing some parallel between the two. Images of this kind frequently concern qualities like beauty, speed, force, power and natural and animal traits.

6 0
4 years ago
Read 2 more answers
Darian has a gourmet cupcake business and needs a website to compete with the other bakeries in his area. He has a Google My Bus
Amiraneli [1.4K]

Answer:

The sequences are given below that is 3, 4, 5, 2, and 1.

Explanation:

The following steps are taken to develop the site via Google My Business.

  • In the first case, He signs his Google My Business.
  • In the second case, the site is accessed from the Home menu.
  • In the third case, the appropriate business details become modified.
  • In the fourth case, he attaches photos, like such a cover picture as well as a virtual guide.
  • In the fifth case, he selects the particular domains as well as directs this to the site.
7 0
4 years ago
Tina reported a safety hazard at her workplace to OSHA. Representatives from OSHA
Anna11 [10]

Answer:

The correct answer is: <em>Protection from Workplace Retaliation</em>

Explanation:

Protection from Workplace Retaliation is one of the 20 Whistleblower Laws enforced by OSHA. According to the Protection from Workplace Retaliation (PFWR) law, employers cannot treat employees unfairly in retaliation to employees reporting  workplace safety hazards to OSHA. The PFWR states that employers cannot retaliate by: denying employees leave, demoting them, firing them, reducing work hours, or denying them promotions.

In this case, Tina's employer violated the Protection from Workplace Retaliation law by giving her menial and difficult jobs in response to her reporting a safety hazard to OSHA.

8 0
3 years ago
A network technician is able to connect the switches between two offices, but the offices cannot communicate with each other, as
Contact [7]

Answer:

C) Router

Explanation:

In computer networking, the router's function is to stand in between diferent data lines and control the flow of data packets.  When a packet arrives from one direction, it reads the address information in the header to determine its direction. Note that the data lines will contain different IP addressing scheme, so considering the scenario in the above question, since the offices use different IP schemes, a router will serve the purpose of directing data packets to allow communication.

6 0
3 years ago
What must be done before using ArrayLists?<br><br> (This is Java Programming btw)
Viktor [21]

Answer:

to create an ArrayList , you declare an Arraylist variable and call the ArrayList constructor to instantiate and ArrayList object and assign it to the variable

5 0
3 years ago
Other questions:
  • Which of the following image file formats uses lossy file compression?
    7·1 answer
  • Without entering into the internet cloud or intranet cloud, how many icons in the topology represent endpoint devices (only one
    6·1 answer
  • An effective team would never have ______.
    13·1 answer
  • Please help me with question 1!
    8·2 answers
  • The stack pop operation
    10·1 answer
  • Give a detailed example of how an app (that you use regularly)uses parameters. You must state the app's name and function, the p
    7·1 answer
  • Initialized the variable with the value 0
    11·2 answers
  • PACIFIC NORTHWEST
    10·1 answer
  • Convert this hexadecimal number to binary :. A07F​
    14·1 answer
  • The following statements regarding centralized administration concepts are presented to you in an interview in which only one of
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!