CS 115 Lab 8, Part B: Draw user-specified flags

[Back to lab instructions]


Instructions

  1. Save lab08a.py file as lab08b.py file and work on the lab08b.py file from this point onwards. In your main function, before calling any of your other functions, ask the user for the width of the graphics window:
    Window width: 700
    When you draw your flags, pass the user's chosen value to the flag functions instead of 700.
  2. You may assume that the user always enters an integer. However, if that integer is not between 100 and 1000 (inclusive), print an error message and exit the program. Here's how to exit the program:
  3. In main, after prompting the user for the window size, print the following menu:
    Which national flag(s) do you want to draw?
    - Japan
    - Bangladesh
    - France
    - Russia
    - Sudan
    Name your country:
  4. Read the user's input. If the user's input is one of the five country names, then call the function that draws that country's flag, and pass it the chosen width. Otherwise, print an error message.
  5. Modify main so that the user's input is case-insensitive. In other words, the inputs JAPAN, Japan, and even JaPaN should all draw the Japanese flag. (Hint: you do NOT have to manually list every possible combination of upper- and lowercase letters.)
  6. Next you will modify your program so that the user can type multiple country names on a line. For example:

    Which national flag(s) do you want to draw?
    - Japan
    - Bangladesh
    - France
    - Russia
    - Sudan
    Name your countries: jaPan FRANCE
    

    Here's what you will need to do:

  7. Print an error message for each word the user typed that does not name a valid country. For example:
    Name your countries: JapaN CS115istan CS115land Russia
    Press ENTER to close the flag window.
    Error: CS115istan is not a valid country.
    Error: CS115land is not a valid country.
    Press ENTER to close the flag window.
  8. When your code is working, call an instructor over to demo.
  9. Continue to Part C.