Zack's dog sitting

Zack runs a dog sitting service where he watches people's dogs for the day. He feeds each dog 2 bones per day, and he takes each dog on 3 walks per day. Zack charges 7 dollars per bone, and 12 dollars per walk.

Zack wrote the following function to determine how much to charge his customers. The function takes the number of dogs (num dogs) and number of days (num days) as input, and returns the total dollars charged as output.

To make his code correct though, he must replace the word CARNIVAL with an integer. What integer should he replace CARNIVAL with?

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# Zack's python code
#
# how_many_dollars()
#
# inputs:
#     num_dogs = number of dogs
#     num_days = number of days
# returns the total charge in dollars

def how_many_dollars(num_dogs, num_days):
    bc = 7
    wc = 12
    bpd = 2
    wpd = 3

    tbc = bc * bpd * num_days * num_dogs
    twc = wpd * CARNIVAL * num_days * num_dogs

    return tbc + twc


The answer is 12.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

The answer is 12 .

twc is a variable holding the total walk cost for num_dogs dogs for num_days days. To calculate twc, you need to multiply (number of walks) by (cost per walk), which equals (num dogs * num days * 3) * 12.

If we look at the line:

twc = wpd * CARNIVAL * num_days * num_dogs

We see that missing integer in the twc calculation is 12 .

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...