Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

**PYTHON** 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

**PYTHON** 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, making sure to include header comments in each one. Header comments count for points! Header comments should take this form: # # SEC290.term_and_year.CRN (e.g. SEC290.FA2022.30040) # Your name # Date # Brief program description (e.g. Hwk4 Step 1) # 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 video Links 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. Here's a video demonstration Links to an external site.of how Step 1 should work. 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. 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. Here's a video demonstration Links to an external site.of how Step 2 should work. 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. Extra credit - 10 points Catch a ZeroDivisionError exception in the event the user has entered 0 for the height attribute. 1. Make a copy of step2.py to use as a starting point for this step. 2. For menu selection "c": Test to see if "width" is in the dictionary. If not, inform the user that the attribute needs to be added and go back to the top of the loop. Test to see if "height" is in the dictionary. If not, inform the user that the attribute needs to be added and go back to the top of the loop. Using a separate variable, convert the width value to an integer using the int() function. Do this in a try block and catch ValueError exceptions which will be caused by a non-numeric width attribute. If an exception is thrown, inform the user that the attribute needs to be re-entered as numeric and return to the top of the while loop, using a continue statement in the except block. Use the same techniques to safely convert the height attribute to an integer, catching any ValueError exception that might be thrown and informing the user. Compute the aspect ratio by dividing the width by the height and display the result to two decimal points using an f-string and a format specifier. Extra credit: If the user has entered a 0 for the height, a ZeroDivisionError exception will be thrown. If so, catch this exception and display a message to the user that the height attribute has to be re-entered with a positive non-zero number. 3. Save the program as step3.py. Here's a video demonstration Links to an external site.of how Step 3 should work. Before submitting your code, check to make sure you have included your header comments in each program Submit all three programs.

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

Recommended Textbook for

Learn Mysql The Easy Way A Beginner Friendly Guide

Authors: Kiet Huynh

1st Edition

B0CNY7143T, 979-8869761545

More Books

Students also viewed these Databases questions