Answered You can hire a professional tutor to get the answer.

QUESTION

First, create the lab08 folder using the mkdir command -- the folder needs to be inside your Labs folder as well. Next, copy a file into your lab08...

First, create the lab08 folder using the mkdir command -- the folder needs to be inside your Labs folder as well.

Next, copy a file into your lab08 folder using the cp command.

cp /afs/umbc.edu/users/k/k/k38/pub/cs201/given_spend.py spending.py

This will copy the file given_spend.py from Dr. Gibson's public folder into your current folder, and will change the file's name to spend.py instead.

The first thing you should do in your file is complete the file header comment, filling in your name, section number, email, and the date.

CMSC 201 - Computer Science I for Majors Page 7

Part 3B: Finishing the Functions

At this point, if you try to run the file, it will only print out the category titles for the expenditures, and nothing else. That is because the file is only partially completed for you.

You will need to update the file to complete the two function definitions, and one function call. If you open the file, you should see comments boxed in by #signs - these are where you need to write new code. Read the function header comments to see the details about the two functions.

You'll need to think carefully about the two-dimensional spending list and how its contents are organized (and how you can access them). It might be helpful to draw a visual representation, and to label the indexes.

For printSpending() and tallySpending(), you'll need to write awhile loop. Make sure to pay attention to what the function's already written code does, as well as things like variable names.

Once both functions are complete, you need to call tallySpending() down in main(), as well as uncommenting the print() statement below it. Youshouldn't need to write any other code.

(See the next page for sample output.)

CMSC 201 - Computer Science I for Majors Page 8

Here is some sample output of the completed program.

There is no user input, and yours should be identical once it's complete.

(The printed list of expenditures for eating out is long enough to wrap around in this document, but is should not wrap around when you run it in the terminal.)

bash-4.1$ python spending.pySpending:EAT OUT :49.3VEHICLE :GROCERIES :UTILITIES :PERSONAL :ENTERTAIN :PET CARE :RENTING :8930.27165.31 17.329.1623.1140.71In category EAT OUTIn category VEHICLEIn category GROCERIESIn category UTILITIESIn category PERSONALIn category ENTERTAINIn category PET CAREIn category RENTINGYou spent a total of.49 was spent.78 was spent.19 was spent.63 was spent.43 was spent.69 was spent.56 was spent was spent.77 this month2515.66100130040.525.9948.9833.0442.45

CMSC 201 - Computer Science I for Majors Page 9

Part 4: Completing Your Lab

Since this is an in-person lab, you do not need to use the submit command to complete your lab. Instead, raise your hand to let your TA know that you are finished.

They will come over and check your work - they may ask you to run your program for them, and they may also want to see your code. Once they've checked your work, they'll give you a score for the lab, and you are free to leave.

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question