For this task, you are to write code that tracks how much money is spent on various leisure activities. Instructions You

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

For this task, you are to write code that tracks how much money is spent on various leisure activities. Instructions You

Post by answerhappygod »

For this task, you are to write code that tracks how much money
is spent on various leisure activities.
Instructions
You like to go out and have a good time on the weekend, but it's
really starting to take a toll on your wallet! To help you keep a
track of your expenses, you've decided to write a little helper
program.
Your program should be capable of recording leisure activities
and how much money is spent on each. You are to add the missing
methods to the LeisureTracker class as described
below.
a) The add_activity method
This method takes the activity
name and the cost of an
activity, and adds it to the total cost for that activity. The
total costs are to be recorded in the activities instance
variable, which references a dictionary object. You will need to
consider two cases when this method is called:
b) The print_summary method
This method takes no arguments, and prints the name and
total cost of each activity (the output
can be in any order, so no sorting required). Additionally, you are
to display the total cost of all
activities and the name of the most
expensive activity. Costs are to be displayed with
two decimal places of precision.
You can assume that add_activity has been called at
least once before print_summary (that is, you don't need
to worry about the leisure tracker not containing any
activities).
Hint: If you don't remember how to iterate over the items in
a dictionary, you may wish to revise Topic 7.
Requirements
To achieve full marks for this task, you must follow the
instructions above when writing your solution. Additionally, your
solution must adhere to the following requirements:
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply