LoginSignup
0
0

More than 3 years have passed since last update.

Python3学習記録#1

Posted at

変数の宣言

variable
# 変数の宣言
age = 18
name = '太郎'
is_ok = True

# 出力
print(age)
print(name)
print(is_ok)

Pythonでは、型の宣言不要。

変数の型の調べ方

variable_type
age = 18
name = '太郎'
is_ok = True

# 変数の型を出力
print(age, type(age))
print(name, type(name))
print(is_ok, type(is_ok))

型がわからないときは、type関数を使う。

型の変換

type_casting
age = 18
number = '18'

# #型の変換(キャスト)
new_age = str(age)
new_number = int(number)

print(new_age, type(age))
print(new_number, type(number))

Pythonはスネークケース

すべての単語を小文字にして、単語と単語はアンダーラインでつなげる。
Pythonは変数や関数でスネークケースを採用しています。

0
0
1

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