Q:

The second root of a number is up to four digits without decomposing it

I want to calculate the root of a number up to four decimal places without rendering and I use the following code but I can not print out the output without rendering the output.
import math
num = float(input('Enter a number: '))
num_sqrt = math.sqrt(num)
print('The square root of %0.4f is %0.4f'%(num ,num_sqrt))

For example, if the inputs are as follows:
1
2
3
19

The output should be as follows:
1.0000
1.4142
1.7320
4.3588

A:

If you're printing only 4 decimals and you don't want the number rounded that means you want the decimals truncated and regular formatting methods don't provide facilities for that.
You can easily achieve that if you pre-process your number as:
def truncate_number(number, decimals):
    factor = 10.0 ** decimals
    return int(number * factor) / factor

num = float(input('Enter a number: '))
num_sqrt = num ** 0.5  # or math.sqrt(num)  if that's what you prefer.
print("The square root of {:.4f} is {:.4f}".format(num, truncate_number(num_sqrt, 4)))

It essentially just multiplies the number with 10^number_of_decimals, truncates the decimals by converting it to an int and then divides it with the same multiplication factor - this, in effect, leaves only the decimals you're interested in.
You don't even nedd to use formatting directives after pre-processing your number as Python won't print trailing zeros so a simple print("The square root of {} is {}".format(num, truncate_number(num_sqrt, 4))) should suffice.

