일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- list
- dataframe
- Apache
- Tkinter
- Google Excel
- gas
- SQL
- django
- matplotlib
- string
- GIT
- Java
- Excel
- PANDAS
- Google Spreadsheet
- Kotlin
- PostgreSQL
- c#
- Mac
- 파이썬
- array
- math
- Redshift
- Python
- google apps script
- Github
- hive
- PySpark
- numpy
- Today
- Total
목록sqrt (5)
달나라 노트
math library의 sqrt() method는 제곱근 값을 return합니다. Syntax math.sqrt(x) x는 어떤 숫자입니다. sqrt() method는 x의 제곱근 값을 return합니다. 예시를 봅시다. import math print(math.sqrt(16)) print(math.sqrt(64)) -- Result 4.0 8.0 - math.sqrt(16) 16의 제곱근은 4이므로 4가 return됩니다. - math.sqrt(64) 64의 제곱근은 8이므로 8이 return됩니다. return값을 보면 4.0, 8.0의 float type입니다. sqrt() method는 float type의 값을 결과로 return합니다.
Math.Sqrt(a)는 어떤 숫자 a를 인자로 받으며 a의 제곱근을 return합니다. using System; class MyProgram { public static void Main() { var sqrt_test = Math.Sqrt(9); Console.WriteLine(sqrt_test); } } -- Result 3 Math.Sqrt(9)는 9의 제곱근을 계산합니다. 따라서 3을 return합니다.
C#에서 Math class는 다양한 수학적인 기능을 제공합니다. Math.Sqrt는 제곱근을 return해줍니다. using System; class MyProgram { static void Main() { int value1 = 9; double result = Math.Sqrt(value1); Console.WriteLine(result); } } -- Result 3 주의할 점은 Sqrt의 결과값은 실수이므로 double 형태로 선언한 result 변수에 Sqrt의 결과를 할당합니다.
numpy의 sqrt는 어떤 수의 제곱근을 계산해줍니다. import numpy as np test_value = np.sqrt(1) print(test_value) test_value = np.sqrt(4) print(test_value) test_value = np.sqrt(9) print(test_value) -- Result 1.0 2.0 3.0 사용법은 간단합니다. 위처럼 그냥 어떤 값을 sqrt method의 parameter로 전달하면 그 값의 제곱근을 계산해줍니다. import numpy as np value_list = [1, 2, 4, 9, 16] result = np.sqrt(value_list) print(result) value_arr = [1, 2, 4, 9, 16] result..