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?

python basic

Posted at

変数

変数名 = 値

x = "hello"
y = 1

文字列

シングルクォーテーション or ダブルクォーテーション
シングルで文字列を書く場合、途中に「'」を使う場合は注意

string1 = "hello"
string2 = "world"

single = "i'm python"

数値

num = 1
num = 2

リスト

JavaScriptでいう配列

list = [1,2,3,4,5]

タブル

定義後に値は変更できない

tuple = (1, 2, 3, 4, 5)
print(tuple)  # (1, 2, 3, 4, 5)
tuple.append(6)
print(tuple) # AttributeError: 'tuple' object has no attribute 'append'

辞書

JavaScriptでいうオブジェクト

dictionaries = {"a": 1, "b": 2, "c": 3}
print(dictionaries["a"])  # prints 1
print(dictionaries.a)  # AttributeError: 'dict' object has no attribute 'a'

真偽値

a = True
b = False

if文

a = 1
if a == 1:
    print("a is 1")
elif a == 2:
    print("a is 2")
else:
    print("a is not 1 or 2")

for文

for i in range(10):
    print(i)  # prints 0 to 9

関数

def fun():
    print("Hello World")

def ret(x):
    return x + 2
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?