April 19th, 2013, 07:22 AM
Join Date: Apr 2013
Time spent in forums: 3 m 35 sec
Reputation Power: 0
Assignment Need Help
I need help!
does someone know how to do this?
could someone do it for me please?
Welcome to Skool-z-Kool, a non-profit organisation that intends to develop simple Python programs for use by school children. The programs will have a dual role: they will be used to teach the younger children simple educational concepts, but will also be used as example programs for user by older children learning to program in Python.
As an enthusiastic volunteer, you have been invited to write a program to introduce young children to some different 2D geometric shapes. Your mentor has suggested that as a pilot study, you write a program dealing with just two shapes: squares and triangles. Both shapes will be drawn on the terminal as a pattern of asterisks (ie, *'s). The program first asks the user what shape is to be drawn, then asks whether the shape should be drawn filled or unfilled, and finally asks for the size. The required shape is then drawn and the program exits.
The program reads three responses from the user (i.e. "standard input") as follows:
1. The shape to draw is requested from the user with the prompt "Enter shape to draw: ". Note that the prompt has a space after the colon.
The only two acceptable inputs, which must be treated case-insensitively, are "square" and "triangle". Any other response results in the error message "Invalid input. Try again." and the prompt for input is repeated. This continues until a valid response is received.
2. The program then prompts the user with "Filled or unfilled? " (Note the space after the question mark).
The user must enter (case-insensitively) either "filled" or "unfilled"; anything else results in the error message "Invalid input. Try again." and the prompt for input is repeated, continuing until valid input is received.
3. The program lastly prompts the user for "Size: " (with a space after the colon).
A response in the range 1 to 100 inclusive is expected. Anything else gives the error message "Invalid input. Try again." and repeats until a valid input is received.
Apart from the prompts and error messages as above, the output from the program is either
a square of asterisks of the given size, unfilled or filled as in the examples below, or
a right-angled triangle with height and base-width of the given size and a vertical left-hand edge, unfilled or filled, as shown below.
The output shape must be preceded by one extra blank line, following the final size prompt line.
For example, a typical run of the program might be:
Enter shape to draw: sqare
Invalid input. Try again.
Enter shape to draw: square
Filled or unfilled? unfilled
Note that in the example output above, the input that is typed by the interactive user is shown in underlined italics. In the examples and test output it is shown in plain text.
Also note, some tests may not be displayed.