Tbalz
asked on
Learning Python and stuck on script
Hi Guys,
I have started to learn Python and I'm completely lost. I wanted to create an object oriented script that would calculate trip cost but I'm getting the wrong output. Can someone please tell me what I'm doing wrong and how i can correct my program below? When I try to get the return of my function Mileageprice_per_gallon I get some weird output like:
I have started to learn Python and I'm completely lost. I wanted to create an object oriented script that would calculate trip cost but I'm getting the wrong output. Can someone please tell me what I'm doing wrong and how i can correct my program below? When I try to get the return of my function Mileageprice_per_gallon I get some weird output like:
<bound method TripCost.Mileageprice_per_gallon of <__main__.TripCost instance at 0x7f28fe0701b8>>
#!/usr/bin/python
class TripCost:
def __init__(self, miles_per_gallon, distance, price_per_gallon):
self.miles_per_gallon = miles_per_gallon
self.distance = distance
self.price_per_gallon = price_per_gallon
def Mileageprice_per_gallon(self):
return (price_per_gallon * distance)
trip1 = TripCost(22, 13.5, 3.27)
print trip1.Mileageprice_per_gallon
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.