0
def multiplo(x):
somamulti= somaImpares(x) + somaPares(x)
if somamulti/10==0:
return somamulti/10
else:
return
In this function I did what happens is the following: the somamulti
sum 2 values, in this case can be 120 + 31 = 151 and my function will first test if this value is multiple of 10, and, if it were, give me this result. otherwise would return me the nearest multiple of 10 greater than or equal to the sum of the two values above, in which case would return me 160.
What I don’t know is how I get to that 160, which means I can’t do the last part of else
.
I don’t know if I understand your problem, I think what you want is just this:
return somamulti / 10 + 1) * 10
http://ideone.com/tNoe4r Got a problem with this? Solve what you want?– Maniero
It doesn’t seem to be the case if .. Lse. As @bigown mentioned, it pays to return the rounded value without doing any testing. One line of code is enough:
return somamulti - ( somamulti % 10 )
would serve well if it were rounded down, with adjustments can round up;– Bacco
@Bacco that would give me 150 and I want the multiples of 10 over 151, ie 160.
– CSAnimor
In this case the code line @bigown gave me works! Thanks! :)
– CSAnimor
@Bigown posts a full answer, I think that’s the case.
– Bacco
Take a look at [tour]. You can accept an answer if it solved your problem. You can vote on every post on the site as well. Did any help you more? You need something to be improved?
– Maniero
Ceil(,-1) does not roll ?
– Motta