チャンネル名:アメリカ発信デベロッパー道
◆概要(引用)
Learning Python in Japanese (working with numbers)
今日は数字のデータの扱い方を紹介します。
今日は数字のデータの扱い方を紹介します。
下のサンプルのコードで試してみてください。
x = 1 # int
y = 2.8 # float
z = 1j # complex
print(type(x))
print(type(y))
print(type(z))
int
x = 1
y = 35656222554887711
z = -3255522
print(type(x))
print(type(y))
print(type(z))
float
x = 1.10
y = 1.0
z = -35.59
print(type(x))
print(type(y))
print(type(z))
import random
print(random.randrange(1, 10))
x = int(1)
y = int(2.8)
z = int(“3”)
print(x)
print(y)
print(z)
x = float(1)
y = float(2.8)
z = float(“3”)
w = float(“4.2”)
print(x)
print(y)
print(z)
print(w)
x = str(“s1”) # x will be ‘s1’
y = str(2) # y will be ‘2’
z = str(3.0) # z will be ‘3.0’
from math import *
print(round(3.7))
print(max(2,5))
a = -5
b = 4
print(min(a,b))
コメント