Answer:
Here is the Python program:
arrow_base_height = int(input('Enter arrow base height: \\')) #prompts user to enter the arrow base height
arrow_base_width = int(input('Enter arrow base width: \\')) #prompts user to enter the arrow base width
arrow_head_width = int(input('Enter arrow head width: \\')) #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: \\')) #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.