Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

python2.7 Write a function called draw_square( k ) that draws a square on the screen with k --- strings on the horizontal plane and k

python2.7

Write a function called draw_square( k ) that draws a square on the screen with k "---" strings on the horizontal plane and k "|" characters on the vertical plane. For example, draw_square( 3 ) draw_square( 5 ) draw_square( 9 ) should print out to the screen. Note that "abc" * 4 duplicates the string "abc" four times resulting in "abcabcabcabc." Hence, you can take advantage of string duplication to solve this question. ASSUME that k > 0. So there is no need for ERROR CHECKING. NOTE that this question can be solved with a 3-line function!!! Try to solve this question using LOOPING, and also try solving it without using LOOPING. Which solution is "better?" Submit only your "better" solution. Hint: Formula (3k - 2)! :)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions