Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The objectives of this assignment focus on step - wise development, menu driven interface using a while loop, dictionaries and secure programming using try /

The objectives of this assignment focus on step-wise development, menu driven interface using a while loop, dictionaries and secure programming using try/except and includes an opportunity for extra credit.
For step-wise development, you'll develop the application in three steps, with points allotted for each step. The idea is to start simple. Don't try and do everything at once. Get one piece of the application to work, build on that success to get the next piece to work and so on. You'll write three separate programs: step1.py, step2.py and step3.py. First you'll complete step1.py, make a copy of it as a starting point for step2.py. Once step2.py is complete, you'll make a copy to use as a starting point for step3.py. Submit all three programs.
The purpose of the application is to build the configuration for a window using a dictionary to define the attributes. You'll provide a user interface, via the while loop, to the user so that the user can choose to enter attributes, display the attributes and determine the aspect ratio (screen width vs. height) of the window. You'll also use secure programming techniques (try/except) to make sure that bad input data cannot crash the program.
Video demonstrations of how each step should work are included at the end of the directions for each step.
Step 1-50 points
In this step, you'll build the basic user interface and create the dictionary. Refer to the Menu Drive Interface videoLinks to an external site. from Week 3.
1. Create an empty dictionary named window_attributes
2. Create a menu display that looks like this:
Window Administration Application
a: Exit application
b: Enter an attribute
c: Calculate and display the aspect ratio.
d: Display the window attributes and values
3. Each time the while loop runs, the menu should be displayed.
4. After displaying the menu, prompt the user to choose a, b, c, or d.
5. If "a" is entered, exit the while loop and display, "Done!".
6. For menu selections b, c and d, simply confirm the selection. The actual work is part of another step.
For "b" indicate, "Entering an attribute selected".
For "c", display "Calculate aspect ratio selected".
For "d", display "Display the attributes and values selected".
7. If the user entered anything else, note that only a, b, c, or d are acceptable (input validation).
8. Save the program as step1.py.
Step 2-30 points
For this step, implement menu selections "b" and "d.
1. Make a copy of step1.py to use as a starting point for this step.
2. For menu selection "b",
Query the user for an attribute name, using the input() command.
Query the user for an attribute value using the input() command.
Store the attribute and value in the dictionary using the attribute as the item key and the value as the item value.
NOTE: Since attribute values could be plain text, e.g. background-color: BLUE, store attribute values as strings.
Display a message confirming that the attribute and value have been stored in the dictionary. Be sure to show the attribute by name and its particular value in the display message, e.g.:
width:800 have been added to the dictionary.
3. For menu selection "d",
Display a message indicating that your program is displaying the window attributes.
Display the attributes and their values on separate lines using a for loop. It should look something like this, depending on which attributes you have entered.
Displaying the window attributes.
width : 800
x-coord : 100
y-coord : 250
height : 600
4. Save the program as step2.py.
Step 3-20 points
For this step, you'll implement menu selection "c". This requires the user to first have entered "width" and "height" attributes. Since the aspect ratio is determined by dividing the width by the height, both attributes must be converted to integers. This is where secure programming practices come into play because it's possible the user has entered something else for the values, which would generate a ValueError exception. You'll also need to check to see that width and height are in the dictionary.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Question

10:16 AM Sun Jan 29 Answered: 1 week ago

Answered: 1 week ago