Created
February 1, 2012 01:56
-
-
Save erkobridee/1714497 to your computer and use it in GitHub Desktop.
um calculo simples que usei para realizar ajustes nas dimensões de imagens
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
def aumentoPercentual(valorInicial, valorPercentual): | |
resultado = math.ceil( valorInicial * valorPercentual ) | |
return valorInicial + resultado | |
def reducaoPercentual(valorInicial, valorPercentual): | |
resultado = math.ceil( valorInicial * valorPercentual ) | |
return valorInicial - resultado | |
valor = 500 | |
percentual = 0.30 | |
print 'valor : ' + str(valor) | |
print 'valor + ' + str(percentual*100) + '% : ' + str(aumentoPercentual(valor, percentual)) | |
print 'valor - ' + str(percentual*100) + '% : ' + str(reducaoPercentual(valor, percentual)) | |
''' | |
valor : 500 | |
valor + 30.0% : 650.0 | |
valor - 30.0% : 350.0 | |
''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment