我想知道如何在python中创建一个平方根,这样当用户键入一个数字时,它会给用户提供该数字的平方根

时间:2016-07-21 04:03:48

标签: python-2.7

请帮我解决这个问题,我已经坚持了几个小时:

如何为用户提供他输入的数字的平方根?希望这个世界上有些人知道如何做到这一点。我在互联网上搜索了几个小时,但我的工作一无所获。

1 个答案:

答案 0 :(得分:0)

import math # So that we can use the sqrt() function
user_inp = float(input())  # takes in user input value and converts it to float
print (math.sqrt(float(user_inp))) #shows the square root answer to the screen