Exercise 3.3: With just the minimum


#1

Before explain my problem I need to tell you I'm performing the course in Latinoamerican spanish, so my variables are in spanish

I have a problem with the exercise 3.3. The exercise ask me to define a function called getMin(), it takes the inputs: saldo and tasa, saldo is the balance of the trip and tasa is the minimun percentage of the balance of the trip. The function should calculate a monthly payment based on the minimum rate. e.g. if the balance is $1000 and the minimum rate is 2% of the balance, the function should return "$20":

def getMin(saldo, tasa):
    pago = saldo * tasa
    return pago

The problem is when I complete the exercise because it ask me: Using your getMin function, make it display the minimum payment of your bills at a rate of 2%.

So the complete code, defining a variable called "bill" that calculates the cost of 5 days in the hotel and calculating the balance with a rate of 2%, is the next:

def costoHotel(dias):
	return 140*dias

factura = costoHotel(5)

def getMin(saldo, tasa):
    pago = saldo * tasa
    return pago

print getMin(factura, 0.2)

When I complie, shows me an error: " Make sure getMin() is shown in your bills"

I don't know what I need to do, please help.


#2

I try editing thus:

def costoHotel(dias):
	return 140*dias

factura = getMin(costoHotel(5), 0.2)

def getMin(saldo, tasa):
    pago = saldo * tasa
    return pago

print factura

But the text error is the same


#3

percent means parts per hundred, so 2% is 2 / 100 which is 0.02 (note that what you printed result differs from what you said above is the correct result)

also, you shouldn't try to use a variable before having defined it (getMin)


#4

So much thanks! My error is in the first code that I used 0.2 when I need to use 0.02.


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.