Difference between revisions of "Print Shapes Exercises"

From WLCS
m (Protected "Print Shapes Exercises" [edit=sysop:move=sysop])
 
Line 7: Line 7:
 
* Prompt the user for a width number
 
* Prompt the user for a width number
 
* Using the height and width, print out a rectangle of *s.
 
* Using the height and width, print out a rectangle of *s.
 +
* HINT: To print out multiple strings all at once, you can multiply a string by a number: '''print( "*" * w )'''
 
* Example:
 
* Example:
  

Latest revision as of 08:25, 13 October 2011

Objective:

  • Become more familiar with looping and printing to the screen

Print Rectangle

  • Prompt the user for a height number
  • Prompt the user for a width number
  • Using the height and width, print out a rectangle of *s.
  • HINT: To print out multiple strings all at once, you can multiply a string by a number: print( "*" * w )
  • Example:
      h = 3
      w = 5

      *****
      *****
      *****

Print Triangle

  • Prompt the user for a number N
  • Print out a triangle that looks like the following:
  • Example:
      N = 4

      *
      **
      ***
      ****