Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Pls! Write a program that outputs the below triangle. The user must input two values. The first input is the character to print for

Python Pls!

image text in transcribedimage text in transcribed

Write a program that outputs the below triangle. The user must input two values. The first input is the character to print for the triangle and the second input is the maximum width of the triangle. Implement the draw() function that takes these two values as parameters. Then, inside this function, you need to use nested loops to print the triangle. The function returns the word 'Done' after outputting the triangle. Hint: First draw the top half, then write a program to draw the bottom half Example 1: if the input Enter Character: % Enter Height: 7 then your program should print: q $$$$$$$ $$ Done Example 2: if the input is Enter Character: + Enter Height: 4 then your program should print: + ++ +++ ++++ +++ ++ + Done If the height given is 1, then you should just print a single character: Enter Character: + Enter Height: 1 then your program should print: + Done main.py Load default template... 1 # Define a function that takes these two values as parameters. 2 def draw character, height): 3 # nested loops and proper return value 4 return 5 6 if __name__=='__main__': 7 # Ask the user to input two values. 8 # Valuel: the first character. 9 # Value2: Traingle height. 10 character=input("Enter Character: ") 11 height=int(input("Enter Height: ') 12 print(draw character, height)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

How can proxy contests be used to overcome a captured board?

Answered: 1 week ago

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago