Skip to content

Instantly share code, notes, and snippets.

@erkobridee
Created February 1, 2012 01:56
Show Gist options
  • Save erkobridee/1714497 to your computer and use it in GitHub Desktop.
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
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