Skip to main content

27 | Square root function

What it is is:

square_root.py

# This program demonstrates the sqrt function.
import math

def main():
# Get a number.
number = float(input('Enter a number: '))

# Get the square root of the number.
square_root = math.sqrt(number)

# Display the square root.
print(f'The square root of {number} is {square_root}.')

# Call the main function.
main()