Skip to content

Instantly share code, notes, and snippets.

@TomoG29
Created November 30, 2023 10:59
Show Gist options
  • Save TomoG29/de0b6fbd763fed2970c3758f69735151 to your computer and use it in GitHub Desktop.
Save TomoG29/de0b6fbd763fed2970c3758f69735151 to your computer and use it in GitHub Desktop.
import math
#########
### 1 ###
#########
print(math.pi)
#結果:3.141592653589793
#########
### 2 ###
#########
print(math.cos(math.pi/2))
#結果:6.123233995736766e-17
print(round(math.cos(math.pi/2)))
#結果:0
print(round(math.cos(math.radians(90))))
#結果:0
print(round(math.sin(math.radians(90))))
#結果:1
print((math.tan(math.radians(90)))
#結果:エラー
print(round(math.tan(math.radians(0))))
#結果:0
#########
### 3 ###
#########
print(math.degrees(math.pi/2))
#結果:90.0
print(math.radians(90))
#結果:1.5707963267948966
#########
### 4 ###
#########
print(math.fabs(-1))
#結果:1.0
#########
### 5 ###
#########
print(f"floor:{math.floor(math.pi)},ceil:{math.ceil(math.pi)},round:{round(math.pi)}")
#結果:floor:3,ceil:4,round:3
val = 5.5
print(f"floor:{math.floor(val)},ceil:{math.ceil(val)},round:{round(val)}")
#結果:floor:5,ceil:6,round:6
#########
### 6 ###
#########
print(math.modf(math.pi))
#結果:(0.14159265358979312, 3.0)
a,b = math.modf(math.pi)
print(f"a = {a},b = {b}")
#結果:a = 0.14159265358979312,b = 3.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment