Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you post the an example of python code following the requirements below *Urgent* 1 Instructions - Create a Python file named yourGroupNumberAsg04.py and post

Can you post the an example of python code following the requirements below *Urgent*
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
1 Instructions - Create a Python file named yourGroupNumberAsg04.py and post it on Canvas. - This is a group assignment. - This assignment's weight is higher: 8% of your grade. - In this assignment you will mainly use the same programming logic from assignment 3 to create a list of contracts and their TAR calculation results. But you will also need to write your list to a file and then read it from a file. I would like you to create a main menu (textbased) that will allow your user to interact with the code a lot more freely. This should be somewhat involved program, however, if you follow the examples that I will point you to and make a few changes to them, life should be a lot easier. - Just like assignment 3 all data must be collected in a list structure (you can also use dictionaries if you like). - Make sure you write your contract list to a file and read from a file (you can use json package to write your dictionaries to a file and read them back. I will show an example in class. You can also use pickle package to write a list to a file and read from a file). - In summary you need to implement (not necessarily in this order-see menu structure given further below): Create multiple functions Use a while loop in main() with a menu structure to call these functions (functions may call other functions) functions acquire variable values for each contract- > use formulas > display results > update the list > ask for a new contract separate function to display the results save results to a file > upload a previously saved file Add new calculations or start from scratch >> Quit - Hint: Look at the Comprehensive List example files to use as a base to your solution. It is much easier to do it that way. You can practically copy and paste some of the functions from there:) Use the JSON version for the easiest option so that you do not need to deal with the spaces in the names, you will need to if you use text read/write. 2 Problem Description SOP (Search Optimization Pro) sells online digital advertising to local business via its sales associates. When a sales associate approaches a local business, he or she tries to convince the local business to let SOP use its experience to manage the business's online advertisements on Google. Facebook, etc. If the sales associate is successful, the business signs a contract with SOP, and they agree on the terms. The contract includes following details: - Monthly advertising budget (b), this is the maximum amount SOP will spend on behalf of the business each month. - Monthly Management Fee (f): $2800+18% of Monthly Ad Spend f=2800+0.18b Based on the terms of the contract we can then estimate the total annual revenue (TAR) earned from a new business as: TAR=s+12f Once a contract is signed and underway, SOP pays annual commission (c) to its sales associate who delivered the contract. The commission amount is set as flat 6% of the total annual revenue of the contract. c=TAR0.06 You are asked to write a program that SOP can use to calculate f, TAR and c given b and s for each contracted sale. Below are the specifics. 3 Program specification - When the program starts it should display the message: Sales and Sales Associate Commissions Tracker by your name here Main Menu: A)dd calculations to an existing file L)oad a file and view results P)rint current results R)eset and perform new TAR calculations S)ave current calculations to a file Q) uit: - To create the menu structure in your main(), use while/if/eliflelse structure. The best example to use to develop the menu structure given above is Comprehensive List Examples I shared. The same example also has load_data and store_data functions which may modify and add to your program to save your results to a file and read them from a file. - Here is how the menu should function (see examples given at the end) A) If user gives ' A ' ( or 'a') you should call your get parameters function to allow user to give new input values. Make sure you are adding the results to an already existing contractList. L) If user gives 'L' (or 'l'), you should then ask for the filename. Then call your load_data function with that file name. Add all values in the file to a contract list. Call your printResults function to display the TAR calculations (like you did in assignment 3 ). Make sure you use exception handling (try/except) so that your program handles exceptions such as FileNotFoundError and other. You can either add this into your load_data() function or in your main(). It is your choice. P) If user gives ' P ' (or ' p ') just call your print Results function to print results. This function should print the results as it did in assignment 3. R) If user gives ' R ' (or ' r ') initialize your contract list (empty list) and ask user for new contract parameters. Display results as users keep adding contracts. This button actually does what your assignment 3 did. S) If user gives ' S ' (or 's') as for a filename and then call your store_data function with that name to write everything that is in the contract list at this point to a file. Note that you are replacing the old file (if user gives the same filename). No need to worry about merging the lists on two files. Q) If user gives ' Q ' or ' q ', just exit the while loop where this menu resides. As long as user does not quit, you should go back and display the same menu (see below for example runs) This portion below describes how acquiring new parameters and TAR calculations work. This is same as assignment 3. - If the user wants to add new contract, note the name of the associate (a) and proceed to obtain the name of the business ( n ) and 2 parameters ( b and s ) you need for the formulas. Instead of asking the additional questions in your main() function, call a new function. Create a function to get all the parameters, validate them and return the validated parameters to variable in the main as multiple return values. Your function that gets these parameters should first ask the name of the business ( n ), then advertising budget (b), and then the agreed setup fee (s). - When each parameter is acquired, you should check to see if the value is valid. Do this with another function (validate function). Make sure that all quantities entered are positive numbers (i.e., not negative and not zero). - If the user fails to enter a valid number display an error message and ask the user to enter again. - Hint - Consider writing a data validation function and calling it from your data acquisition function. You can do the data validation function after getting all other functions working first. That is what I did. (Example of this is/will be given in class) - When all input variables are obtained pass these values to new function that will calculate f, TAR and c. Do not display the results at this point. Instead your calculation function should save all seven values in a list. At each iteration, you should update the same list. A list is a data structure that is very easy to use, for instance contractList = defines the empty list. contractList.append([a, n,b,s,f,TAR,c]) adds to this list. - You can then use a for loop to iterate over the list to read the results and print them. Do this in a separate function. I gave more on this in class, along with examples. - Do NOT use global variables in your program. Instead, pass the parameter values to your functions and return the variables of interest after calculations from those functions. Note Typically it is not a good idea to create functions to do more than one thing (your calculation function will calculate three quantities: f,TAR, and c. Later we will split this into multiple functions. I want you to practice returning and unpacking multiple values from Python functions. After you save all parameters and calculations for each contract in your contractList, go back to your initial question Enter the name of the sales associate or q to quit: - Once the user quits display the results as a table (see below) with 7 columns. See the sample run to see how values actually should look. The results given below should be achieved using a print function you should write (printList is the name I used). This function should take the contractList and print it. After printing the table, your function should also print the three-line summary of the table. Use the following rules for displaying the results. - Use two significant digits for numbers. Everything is left justified. - Here is a sample run to see how the messages/output should work. - Saving results to a file (contractList as a default file) - I then do one more contract calcs and save the new list to the file again. onate ond \# mad ond - So, filename is a parameter that must be fed into load and store (save) functions you create. Handling default name is a bit tricky, so don't worry about that. Let the user give you a correct filename to save and then remember the same name. Defaults are used so that users don't have to remember. But you are not responsible for them for this assignment

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

Databases Illuminated

Authors: Catherine M. Ricardo

1st Edition

0763733148, 978-0763733148

More Books

Students also viewed these Databases questions

Question

Can anyone else provide additional information?

Answered: 1 week ago

Question

2 What participation techniques are used?

Answered: 1 week ago