Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

322
Visualizações
Python - How can I get the largest decimal of two decimals

I have two values of type decimal i.e <class 'decimal.Decimal'> and <class 'decimal.Decimal'> and the numbers are

print(option.principal.amount, 'and', max_monthly_amount.amount)

Outputs

500000.00 and 500000

Getting max of the two values like this

option.principal.amount.max(max_monthly_amount.amount)

Returns

'decimal.Decimal' object has no attribute 'max_term'
over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

You can do this with the max function in the standard library:

max(option.principal.amount, max_monthly_amount.amount))
over 4 years ago · Santiago Trujillo Relatório

0

you should convert both of them to float and then use max function this way :

num1 = float(option.principal.amount)
num2 = float(max_monthly_amount.amount)
print(max(num1, num2))
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda