Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Python Tutorial
  • Interview Questions
  • Python Quiz
  • Python Glossary
  • Python Projects
  • Practice Python
  • Data Science With Python
  • Python Web Dev
  • DSA with Python
  • Python OOPs
Open In App
Next Article:
Python | Decimal max_mag() method
Next article icon

Python | Decimal max() method

Last Updated : 17 Sep, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report

Decimal#max() : max() is a Decimal class method which compares the two Decimal values and return the max of two.

  Syntax:  Decimal.max()    Parameter:  Decimal values    Return:  the max of two.  

Code #1 : Example for max() method




# Python Program explaining 
# max() method
  
# loading decimal library
from decimal import *
  
  
# Initializing a decimal value
a = Decimal(-1)
  
b = Decimal('0.142857')
  
# printing Decimal values
print ("Decimal value a : ", a)
print ("Decimal value b : ", b)
  
  
# Using Decimal.max() method
print ("\n\nDecimal a with max() method : ", a.max(a))
  
print ("Decimal a with max() method : ", a.max(b))
  
print ("Decimal b with max() method : ", b.max(a))
 
 

Output :

  Decimal value a :  -1  Decimal value b :  0.142857      Decimal a with max() method :  -1  Decimal a with max() method :  0.142857  Decimal b with max() method :  0.142857    

Code #2 : Example for max() method




# Python Program explaining 
# max() method
  
# loading decimal library
from decimal import *
  
  
# Initializing a decimal value
a = Decimal('-3.14')
  
b = Decimal('321e + 5')
  
# printing Decimal values
print ("Decimal value a : ", a)
print ("Decimal value b : ", b)
  
  
# Using Decimal.max() method
print ("\n\nDecimal a with max() method : ", a.max(a))
  
print ("Decimal a with max() method : ", a.max(b))
  
print ("Decimal b with max() method : ", b.max(a))
 
 

Output :

  Decimal value a :  -3.14  Decimal value b :  3.21E+7      Decimal a with max() method :  -3.14  Decimal a with max() method :  3.21E+7  Decimal b with max() method :  3.21E+7  


Next Article
Python | Decimal max_mag() method

N

noobestars101
Improve
Article Tags :
  • Python
  • Python-Functions
Practice Tags :
  • python
  • python-functions

Similar Reads

  • Python | Decimal max_mag() method
    Decimal#max_mag() : max_mag() is a Decimal class method which compares the two Decimal values and return the max of two, with their sign ignored. Syntax: Decimal.max_mag() Parameter: Decimal values Return: the max_mag of two, with their sign ignored. Code #1 : Example for max_mag() method # Python P
    2 min read
  • Python | Decimal exp() method
    Decimal#exp() : exp() is a Decimal class method which returns the value of the (natural) exponential function e**x at the given number Syntax: Decimal.exp() Parameter: Decimal values Return: the value of the (natural) exponential function e**x at the given number Code #1 : Example for exp() method #
    2 min read
  • Python | Decimal ln() method
    Decimal#ln() : ln() is a Decimal class method which returns the natural (base e) logarithm of the Decimal value. Syntax: Decimal.ln() Parameter: Decimal values Return: the natural (base e) logarithm of the Decimal value. Code #1 : Example for ln() method # Python Program explaining # ln() method # l
    2 min read
  • Python | Decimal min_mag() method
    Decimal#min_mag() : min_mag() is a Decimal class method which compares the two Decimal values and return the minimum of two, with their sign ignored. Syntax: Decimal.min_mag() Parameter: Decimal values Return: minimum of two, with their sign ignored. Code #1 : Example for min_mag() method # Python P
    2 min read
  • Python | Decimal logb() method
    Decimal#logb() : logb() is a Decimal class method which returns the adjusted exponent of the Decimal value. Syntax: Decimal.logb() Parameter: Decimal values Return: the adjusted exponent of the Decimal value. Code #1 : Example for logb() method # Python Program explaining # logb() method # loading d
    2 min read
  • Python | Decimal log10() method
    Decimal#log10() : log10() is a Decimal class method which returns the base ten logarithm of the Decimal value. Syntax: Decimal.log10() Parameter: Decimal values Return: the base ten logarithm of the Decimal value. Code #1 : Example for log10() method # Python Program explaining # log10() method # lo
    2 min read
  • Python | Decimal min() method
    Decimal#min() : min() is a Decimal class method which compares the two Decimal values and return the min of two. Syntax: Decimal.min() Parameter: Decimal values Return: the min of two. Code #1 : Example for min() method # Python Program explaining # min() method # loading decimal library from decima
    2 min read
  • Python | Decimal is_nan() method
    Decimal#is_nan() : is_nan() is a Decimal class method which checks whether the Decimal value is NaN value. Syntax: Decimal.is_nan() Parameter: Decimal values Return: true - if the Decimal value is NaN value; otherwise false Code #1 : Example for is_nan() method # Python Program explaining # is_nan()
    2 min read
  • Python | Decimal sqrt() method
    Decimal#sqrt() : sqrt() is a Decimal class method which returns the Square root of a non-negative number to context precision. Syntax: Decimal.sqrt() Parameter: Decimal values Return: the Square root of a non-negative number to context precision. Code #1 : Example for sqrt() method # Python Program
    2 min read
  • Python List max() Method
    max() function in Python is a built-in function that finds and returns the largest element from the list. Let's understand it better with an example: [GFGTABS] Python a = [2,3,6,1,8,4,9,0] print(max(a)) [/GFGTABS]Output9 Syntaxmax(listname) Parameter: listname : Name of list in which we have to find
    4 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences