Python | Decimal shift() method Last Updated : 05 Sep, 2019 Comments Improve Suggest changes Like Article Like Report 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 Python3 # Python Program explaining # shift() method # loading decimal library from decimal import * # Initializing a decimal value a = Decimal(1) b = Decimal(2) # printing Decimal values print ("Decimal value a : ", a) print ("Decimal value b : ", b) # Using Decimal.shift() method print ("\n\nDecimal a with shift() method : ", a.shift(b)) print ("Decimal b with shift() method : ", b.shift(b)) Output : Decimal value a : 1 Decimal value b : 2 Decimal a with shift() method : 100 Decimal b with shift() method : 200 Code #2 : Example for shift() method Python3 # Python Program explaining # shift() method # loading decimal library from decimal import * # Initializing a decimal value a = Decimal(300) b = Decimal(15) # printing Decimal values print ("Decimal value a : ", a) print ("Decimal value b : ", b) # Using Decimal.shift() method print ("\n\nDecimal a with shift() method : ", a.shift(b)) print ("Decimal b with shift() method : ", b.shift(b)) Output : Decimal value a : 300 Decimal value b : 15 Decimal a with shift() method : 300000000000000000 Decimal b with shift() method : 15000000000000000 Comment More infoAdvertise with us Next Article Python | Decimal shift() method N noobestars101 Follow Improve Article Tags : Python Practice Tags : python Similar Reads 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 Python3 # Python 2 min read Python | Decimal scaleb() method Decimal#scaleb() : scaleb() is a Decimal class method which returns the first operand after adding the second value its exp. Syntax: Decimal.scaleb() Parameter: Decimal values Return: the first operand after adding the second value its exp. Code #1 : Example for scaleb() method Python3 # Python Prog 2 min read Python | Decimal copy_sign() method Decimal#copy_sign() : copy_sign() is a Decimal class method which returns the copy of the first Decimal value with the sign set to be the same as the sign of the second Decimal value. Syntax: Decimal.copy_sign() Parameter: Decimal values Return: the copy of the first Decimal value with the sign set 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 Python3 # Python Program explaining # ln() me 2 min read Python | Decimal to_eng_string() method 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 Python3 # Python Pr 2 min read Like