Change language

Python | Decimal method to_eng_string ()

|

Decimal # to_eng_string (): to_eng_string () — it is a Decimal method that converts to a string using engineering notation if exponent is required.

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 ` ` * `     ` # Initialize decimal value ` ` a ` ` = ` ` Decimal (` ` 1.898989 ` `) `   ` b ` ` = ` ` Decimal (` ` 2.0 ` `) ` ` `  ` # print decimal values ​​` ` print ` ` (` ` "Decimal value a:" ` `, a) ` ` print ` ` (` ` "Decimal value b:" ` `, b) `     ` # Using the Decimal.to_eng_string () method ` ` print ` < code class = "plain"> ( ` "Decimal 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_bpre> Code  Code / p>         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

Shop

Learn programming in R: courses\$

Best Python online courses for 2022\$

Best laptop for Fortnite\$

Best laptop for Excel\$

Best laptop for Solidworks\$

Best laptop for Roblox\$

Best computer for crypto mining\$

Best laptop for Sims 4\$

Latest questions

NUMPYNUMPY
Common xlabel/ylabel for matplotlib subplots

NUMPYNUMPY
How to specify multiple return types using type-hints

NUMPYNUMPY
Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

NUMPYNUMPY
Flake8: Ignore specific warning for entire file

NUMPYNUMPY
glob exclude pattern

NUMPYNUMPY
How to avoid HTTP error 429 (Too Many Requests) python

NUMPYNUMPY
Python CSV error: line contains NULL byte

NUMPYNUMPY
csv.Error: iterator should return strings, not bytes

All questions

News

07/12/2022
Microsoft intends to create a superapp with a search engine and messenger

04/12/2022
Chrome OS 108 is released

27/11/2022
The long-awaited ARPlAN app update for Android is out

Wiki

File handling

Python | How to copy data from one Excel sheet to another

__dict__

Common xlabel/ylabel for matplotlib subplots

__dict__

Check if one list is a subset of another in Python

sin

How to specify multiple return types using type-hints

exp

Printing words vertically in Python

exp

Python Extract words from a given string

Python functions

Cyclic redundancy check in Python

Counters

Finding mean, median, mode in Python without libraries

cos

__dict__

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

Python functions

Python - Move item to the end of the list

Loops

Python - Print list vertically

EN | ES | DE | FR | IT | RU | TR | PL | PT | JP | KR | CN | HI | NL

Python.Engineering is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to amazon.com

Python

Loops
Counters
NumPy
NLP
Regular Expressions

Wiki

Tech news
Python Wiki
StackOverflow
PHP
JavaScript

Books

All books
Computations
Development
Cryptography
For dummies
Big Data

` # Python program explaining `  ` # to_eng_string () method `   ` `  ` # decimal library loading `   ` from ` ` decimal ` ` import ` ` * `      ` `  ` # Initialize decimal value `   ` a ` ` = ` ` Decimal (` ` 3.14 ` `) `  ` `   ` b ` ` = ` ` Decimal (` ` 15 ` `) `       ` # print decimal values ​​`   ` print ` ` (  "Decimal value a:"  , a) ``   print   (  "Decimal value b:"  , b)          # Using the Decimal.to_eng_string () method     print   (  "Decimal a with to_eng_string () method:"  , a.to_eng_string ())        print   ( " Decimal b with to_eng_string () method: " , b.to_eng_string ()) `

let arrayCode = document.querySelectorAll('pre');
arrayCode.forEach(element => {
});
});

window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'G-Q022WLXW4X');

```