Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

320
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!