Python after calculating the square root of 2, and outputs the first decimal numbers 1,000,000

 

Import numpy AS NP
 from decimal Import * # Set the number of bits 
n-int = (INPUT ( " Please enter the number of bits: " )) 
getContext () prec. =. 1 + n-
 # square root 
Result = np.sqrt (a Decimal (2 ))
 # number into a string and extracts the last 
End = STR (result) [-. 1 :]
 # printing result Print ( " squared result: " , result)
 Print ( " total data after the decimal point: " , len (STR ( Result)) - 2 )
 Print ( " one decimal digit {}: {} " .format (n-, End))


Test results: 10

 

 

Test results: 1,000,000

 

Guess you like

Origin www.cnblogs.com/jumpkin1122/p/11575480.html