일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- PySpark
- PostgreSQL
- django
- Mac
- dataframe
- Java
- Google Spreadsheet
- google apps script
- matplotlib
- 파이썬
- list
- Redshift
- hive
- Excel
- c#
- Apache
- Github
- GIT
- PANDAS
- Google Excel
- string
- SQL
- math
- Kotlin
- gas
- array
- Tkinter
- Python
- numpy
- Today
- Total
목록거듭제곱 (3)
달나라 노트
math library의 pow() method는 거듭제곱의 결과를 return합니다. Syntax math.pow(x, y) x, y는 숫자입니다. pow() method는 x^y 의 결과를 return합니다. 예시를 봅시다. import math print(math.pow(2, 3)) print(math.pow(10, 4)) -- Result 8.0 10000.0 - math.pow(2, 3) 2^3의 결과는 8이므로 8이 return됩니다. - math.pow(10, 4) 10^4의 결과는 10000이므로 10000이 return됩니다. return값을 보면 8.0, 10000.0으로 모두 float type으로 return됩니다.
Math.Pow(a, b) method는 a^b 값을 return합니다. using System; class MyProgram { public static void Main() { var pow_test = Math.Pow(2, 10); Console.WriteLine(pow_test); } } -- Result 1024 Math.Pow(2, 10)은 2^10을 계산하여 return합니다. 따라서 1024라는 값이 return됩니다.
3의 5승(3 ^ 5)을 영어로 표현하면 3 to the power of 5 입니다. 이렇게 거듭제곱을 표현하는 단어는 영어에서 power라는 단어인데 이 단어의 앞글자를 딴 method가 Python에 존재합니다. pow(n, m) .위처럼 사용할 수 있으며 n의 m승(n ^ m)을 의미합니다. print(pow(2, 3)) print(pow(3, 2)) print(pow(8, 2)) -- Result 8 9 64