0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

python初学者の備忘録 型について

Last updated at Posted at 2021-09-13

####←目次へ

python,Qiita初心者なので、備忘録として記載していきます。
なにせ初心者なので、知識不足はご理解ください。
知識を深めながら追記していきたいと思います。

#データ型とは

基本

[*int型(整数型)*](https://qiita.com/dondondon/items/1c7ff18c2d9627772e8e)
例:「1」「-5」など
[*float型(浮動小数型)*](https://qiita.com/dondondon/items/1c7ff18c2d9627772e8e)
例:「0.1」
[*str型(文字列型)*](https://qiita.com/dondondon/items/75326c64e1704ed35493)
例:「あ」
[*bool型(ブール型)*](https://qiita.com/dondondon/items/412b8e5c147cc3c0c38f)
例:「True」「False」

#型を調べる

type()関数:型を返す

type.py
number = 1
number2 = 1.0
number3 = '1.0'
greeting = 'こんにちは' または "こんにちは"
is_ok = True
print(number,type(number))
print(number2 ,type(number))
print(number3 ,type(number))
print(greeting ,type(number))  
print(is_ok ,type(number))

# -- 実行結果 --
# 1 <class 'int'>           # -- 数値型 --
# 1.0 <class 'float'>       # -- 浮動小数型 --
# '1.0' <class 'str'>       # -- 数値型に見えるが文字列 --
# こんにちは <class 'str'>   # -- 文字列型 --
# True <class 'bool'>       # -- ブール型 --
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?