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 Strings decode() method
Next article icon

Python | Decimal to_eng_string() method

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

Decimal#to_eng_string() : to_eng_string() is a Decimal class method which converts to a string, using engineering notation if an exponent is needed.

Syntax: Decimal.to_eng_string()

Parameter: Decimal values

Return: converts to a string

Code #1 : Example for to_eng_string() method




# Python Program explaining 
# to_eng_string() method
  
# loading decimal library
from decimal import *
  
  
# Initializing a decimal value
a = Decimal(1.898989)
  
b = Decimal(2.0)
  
# printing Decimal values
print ("Decimal value a : ", a)
print ("Decimal value b : ", b)
  
  
# Using Decimal.to_eng_string() method
print ("\n\nDecimal a with to_eng_string() method : ", a.to_eng_string())
  
print ("Decimal b with to_eng_string() method : ", b.to_eng_string())
 
 

Output :

  Decimal value a :  1.8989890000000000380708797820261679589748382568359375  Decimal value b :  2      Decimal a with to_eng_string() method :  1.8989890000000000380708797820261679589748382568359375  Decimal b with to_eng_string() method :  2    

Code #2 : Example for to_eng_string() method




# Python Program explaining 
# to_eng_string() method
  
# loading decimal library
from decimal import *
  
  
# Initializing a decimal value
a = Decimal(3.14)
  
b = Decimal(15)
  
  
# printing Decimal values
print ("Decimal value a : ", a)
print ("Decimal value b : ", b)
  
  
# Using Decimal.to_eng_string() method
print ("\n\nDecimal a with to_eng_string() method : ", a.to_eng_string())
  
print ("Decimal b with to_eng_string() method : ", b.to_eng_string())
 
 

Output :

  Decimal value a :  3.140000000000000124344978758017532527446746826171875  Decimal value b :  15      Decimal a with to_eng_string() method :  3.140000000000000124344978758017532527446746826171875  Decimal b with to_eng_string() method :  15    


Next Article
Python Strings decode() method

N

noobestars101
Improve
Article Tags :
  • Python
Practice Tags :
  • python

Similar Reads

  • Python string isdecimal() Method
    In Python, the isdecimal() method is a quick and easy way to check if a string contains only decimal digits. It works by returning True when the string consists of digits from 0 to 9 and False otherwise. This method is especially useful when we want to ensure that user inputs or string data are stri
    3 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 | Decimal shift() method
    Decimal#shift() : shift() is a Decimal class method which returns the shifted copy of x, y times Syntax: Decimal.shift() Parameter: Decimal values Return: the shifted copy of x, y times Code #1 : Example for shift() method # Python Program explaining # shift() method # loading decimal library from d
    2 min read
  • Python Strings decode() method
    The decode() method in Python is used to convert encoded text back into its original string format. It works as the opposite of encode() method, which converts a string into a specific encoding format. For example, let's try to encode and decode a simple text message: [GFGTABS] Python s = "Geek
    4 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 is_zero() method
    Decimal#is_zero() : is_zero() is a Decimal class method which checks whether the Decimal value is zero value. Syntax: Decimal.is_zero() Parameter: Decimal values Return: true - if the Decimal value is zero value; otherwise false Code #1 : Example for is_zero() method # Python Program explaining # is
    2 min read
  • Python | Decimal is_snan() method
    Decimal#is_snan() : is_snan() is a Decimal class method which checks whether the Decimal value is a signaling NaN Syntax: Decimal.is_snan() Parameter: Decimal values Return: true - if the Decimal value is a signaling NaN; otherwise false Code #1 : Example for is_snan() method # Python Program explai
    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 as_integer_ratio() method
    Decimal#as_integer_ratio() : as_integer_ratio() is a Decimal class method which returns the exponent after shifting out the coefficient’s rightmost digits until only the lead digit remains : as a pair (n, d) Syntax: Decimal.as_integer_ratio() Parameter: Decimal values Return: the exponent after shif
    2 min read
  • Python - Strings encode() method
    String encode() method in Python is used to convert a string into bytes using a specified encoding format. This method is beneficial when working with data that needs to be stored or transmitted in a specific encoding format, such as UTF-8, ASCII, or others. Let's start with a simple example to unde
    3 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