python exercises 3.6: square root format

6. Format root

Describes
obtaining a user input of an integer, a calculation of the square root of 3 digits after the decimal point, and prints.

30 using the output character width, the output right-justified, the extra character is a plus sign (+) is filled.

If the result is more than 30 characters, it is subject to the result width.

‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‫‬

Example O
[Image dump the chain fails, the source station may have security chain mechanism, it is recommended to save the picture down uploaded directly (img-pefhkXdO-1584279848679) (attachment: image.png)]

a = int(input())
result = pow(a, 0.5)
print("{:+>30.3f}".format(result))
9999999
++++++++++++++++++++++3162.278

note

Study title source for Python123 platform and Chinese University of MOCC "Python Programming Language" course, Speaker Teacher: Song days, Huang Tianyu, Yan ceremony. If infringement, stand deleted.

Published 59 original articles · won praise 35 · views 1738

Guess you like

Origin blog.csdn.net/weixin_43412569/article/details/104887165