Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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