Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

help! Can you answer #3 print_upper_right_triangle and 5 print_lower_right_triangle 2. Write a function print_upper_left_triangle(ch, height) that prints out the character ch in the shape of

help! image text in transcribed
image text in transcribed
image text in transcribed
Can you answer #3 print_upper_right_triangle and 5 print_lower_right_triangle
2. Write a function print_upper_left_triangle(ch, height) that prints out the character ch in the shape of an upper left triangle of size height. For example: >>> print_upper_left_triangle('*', 5) HINTI Since the number of characters printed changes with each row (i.e., inside the loop). you should calculate the number of spaces and put the number in a variable) to print and use that value to control the printing. 3. Write a function print_upper_right_triangle(ch, height) that prints out the character ch in the shape of an upper right triangle of size height. For example: >>> print_upper_right_triangle('*', 5) HINT! Since the number of spaces before the output changes with each row (i.e., inside the loop), you should calculate the number of spaces and put the number in a variable) to print and use that value to control the printing. 4. Write a function print_lower_left_triangle(ch, height) that prints out the character ch in the shape of a lower left triangle of size height. For example: >>> print_lower_left_triangle("*', 5) Mail-Maris. https://learn... Video Exam... 18. My Courses... systems ph... Assignment. 5. Write a function print_lower_right_triangle(ch, height) that prints out the character ch in the shape of a lower right triangle of size height. For example: >>> print_lower_right_triangle('*, 5) 6. Write a function print.pyramid(ch, height) that prints out the character ch in the shape of a pyramid of size height. For example: >>> print_pyramid("',5) 7. Write a function print_diamond(ch, height) that prints out the character ch in the shape of a diamond of size height. For example: >>> print_diamond('',10) Another hint!! These examples all orint out stars (8) but our functions should be able to print ANY Nof Secure https://arn. cs-people.bu.edu Video Exam... systems ph M ali- Maris.. My Courses Assignment... CH The objective of this part is to get you comfortable working with the for loop and the range function. Create a file called a86 printing shapes.py. Write the following functions to print out the required patterns. The following functions must print out the required pattern, but do not have any return value. Test your work thoroughly. Put your test cases in the main section at the bottom of your file, i.e., _name__ == '_main print_rect('', print Do not overthink these problems! None of these problems requires if/else logic, and none requires nested loops. . When using the built-in range function for these problems, you must give the range function exactly one parameter - When to stop Recall that you can repeat a string using the operator. Try it: print("hello" - 5), Experimentation is your friend. Don't be afraid to try something, run the code try something else. It is also helpful to draw out on paper what you want to achieve, and figure out how to relate it to using loops. 1. Write a function print_rect(ch, width, height) that prints out the character ch in the shape of a rectangle. The rectangle should have the dimensions width. height. For example: >>> print_rect('', 7, 5)

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

SQL Server Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

More Books

Students also viewed these Databases questions

Question

1. What are your creative strengths?

Answered: 1 week ago