
Problem
Solution
Submissions
Find the Square Root of a Number
Certification: Basic Level
Accuracy: 82.8%
Submissions: 186
Points: 5
Write a Python program that calculates the square root of a given number.
Example 1
- Input: 16
- Output: 4.0
- Explanation:
- Step 1: Calculate the square root of 16.
- Step 2: √16 = 4.0.
- Step 3: Return 4.0 as the result.
Example 2
- Input: 7
- Output: 2.6457513110645907
- Explanation:
- Step 1: Calculate the square root of 7.
- Step 2: √7 = 2.6457513110645907.
- Step 3: Return 2.6457513110645907 as the result.
Constraints
- 0 ≤ number ≤ 10^9
- Return the result with full precision
- Time Complexity: O(1) or O(log n) if implementing manually
- Space Complexity: O(1)
Editorial
My Submissions
All Solutions
Lang | Status | Date | Code |
---|---|---|---|
You do not have any submissions for this problem. |
User | Lang | Status | Date | Code |
---|---|---|---|---|
No submissions found. |
Solution Hints
- Use math.sqrt() function: import math; result = math.sqrt(num)
- Use the exponentiation operator: result = num ** 0.5
- Implement Newton's method for manual calculation
- Use binary search method for manual implementation