Calculating Square Root

Write a Python program that uses the math module to calculate the square root of a user input number. Return the square root.

Example 1:

Input: 25
Output: 5.0

Example 2:

Input: 81
Output: 9.0

The math module in Python provides a function sqrt() that calculates the square root of the number.

import math

def calculate_sqrt(num):
    return math.sqrt(num)

print(calculate_sqrt(25))  # Output: 5.0
print(calculate_sqrt(81))  # Output: 9.0

© Let’s Data Science

LOGIN

Unlock AI & Data Science treasures. Log in!