Question: 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
Get step-by-step solutions from verified subject matter experts
