What will the program output when you run
 vanilla = IceCream("vanilla", 4, 2, 10)
print vanilla.total_cost()

Using the below code?
Try to walk through the program in your head to find the answer before you actually run the code.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22  class IceCream(object):
def __init__(self, flavor, numScoops, costPerScoop, remaining_icecream):
self.flavor = flavor
self.numScoops = numScoops
self.costPerScoop = costPerScoop
self.remaining_icecream = remaining_icecream
def scoop(self):
#shows the amount of ice cream remaining after an order is scooped
#scoops icecream and decreases the number of scoops left
self.remaining_icecream = self.numScoops
return self.remaining_icecream
def total_cost(self):
#vanilla ice cream is sold at a discount of half off!
if self.flavor == "vanilla":
total_cost = self.numScoops * .5*self.costPerScoop
else:
total_cost = self.numScoops * self.costPerScoop
return total_cost
