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.pyThis 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 7Part 3B: Finishing the FunctionsAt 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 8Here 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.)CMSC 201 – Computer Science I for Majors Page 9Part 4: Completing Your LabSince 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.
The post First, create the lab08 folder using the mkdir command — the folder needs to be appeared first on Stanford Papers.