Hello. I'm using functions in my python code. I'm not sure how to get the output.
Hello. I'm using functions in my python code.
I'm not sure how to get the output.



Solution-We have created a program should have a main function that reads three inputs - a symbol and 2 integer values, and we draws the figures similar to the sample run. function main should call the drawRectangle and draw Triangle functions.
- Using a loop in drawBar(symbol, length) function to draw horizontal bar of length with the given symbol. drawRectangle(symbol, width, height) function takes three arguments, then calls the drawBar function.
draw Triangle(symbol, height) function takes two arguments, then calls the drawBar function. And Your output should match the given sample runs that you can see in given solution- - We use an python3 code to create an program .
- Code is shown below-
# filename :
# Name :
# Summary: The supplied height, width, and symbol are printed for the rectangle and triangle in this application.
def drawBar(symbol, length):
for i in range(length):
print(symbol,end='')
print()
def DrawRectangle(symbol, width, height):
for i in range(height):
drawBar(symbol, width)
def DrawTriangle(symbol, height):
for i in range(height):
drawBar(symbol, i+1)
for i in range(height-1,0,-1):
drawBar(symbol, i)
def DrawOptional(symbol, height):
for i in range(1,height):
for j in range(height-i):
print(' ',end='')
drawBar(symbol, 2*i-1)
def main():
symbol = input("Enter the symbol for the shapes: ")
width = int(input("Enter the width of the shape: "))
height = int(input("Enter the height of the shapes: "))
print()
DrawRectangle(symbol, width, height)
print()
DrawTriangle(symbol, height)
main()
Output-
Enter the symbol for the shapes: X
Enter the width of the shape: 7
Enter the height of the shapes: 5
XXXXXXX
XXXXXXX
XXXXXXX
XXXXXXX
XXXXXXX
X
XX
XXX
XXXX
XXXXX
XXXX
XXX
XX
X
Step by step
Solved in 2 steps with 3 images









