Skip to content

Commit fc4ca30

Browse files
authored
docs (python-008): improve doc
1 parent 81e56dc commit fc4ca30

File tree

1 file changed

+17
-7
lines changed
  • content/post/tutorial-python-008

1 file changed

+17
-7
lines changed

content/post/tutorial-python-008/index.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,32 @@ tags:
3232

3333
配列をコードで表す場合は、`array1 = ["a", "b", "c", "d"]` のように宣言することができます。
3434

35-
また、`array1[0]``array1[1]` のように指定することで、それぞれの要素 `"a"``"b"` などを取り出すことができます。
35+
例:
36+
```python
37+
books = ["Murder on the Orient Express", "The ABC Murders", "And Then There Were None", "Dead Man's Folly"]
38+
```
3639

37-
これを先程の例で示すと、以下のコードになります
40+
また、`array1[0]``array1[1]` のように指定することで、それぞれの要素 `"a"``"b"` などを取り出すことができます
3841

3942
例:
4043
```python
4144
books = ["Murder on the Orient Express", "The ABC Murders", "And Then There Were None", "Dead Man's Folly"]
4245

43-
print(books) # 配列全体を出力
44-
# 出力> ['Murder on the Orient Express', 'The ABC Murders', 'And Then There Were None', "Dead Man's Folly"]
45-
4646
print(books[0]) # 配列の1番目を出力 (配列は0から数えるので、1番目を出力する場合は0を指定する)
4747
# 出力> Murder on the Orient Express
4848

4949
print(books[1]) # 配列の2番目を出力 (配列は0から数えるので、2番目を出力する場合は1を指定する)
5050
# 出力> The ABC Murders
51+
```
52+
53+
その他に以下のようなことも可能です。
54+
55+
例:
56+
```python
57+
books = ["Murder on the Orient Express", "The ABC Murders", "And Then There Were None", "Dead Man's Folly"]
58+
59+
print(books) # 配列全体を出力
60+
# 出力> ['Murder on the Orient Express', 'The ABC Murders', 'And Then There Were None', "Dead Man's Folly"]
5161

5262
# 配列を利用してそれぞれの要素を出力
5363
for i in range(len(books)): # len(books) は配列の長さ。これは1から数えるので、4が返される
@@ -68,7 +78,7 @@ numbers = [6, 1, 52, 30, 3]
6878
print(numbers[0])
6979
# 出力> 6
7080

71-
# 配列の数値を利用して計算もできます。
81+
# 配列の数値を利用して計算する
7282
cal = numbers[0] + numbers[1]
7383
print(cal)
7484
# 出力> 7
@@ -86,4 +96,4 @@ print(numbers)
8696
応用的な内容や、2次元配列などについては追記するかもしれません。
8797

8898
---
89-
Last Code Checked 2024/7/12 by [mint73](https://github.com/mint73)
99+
Last Code Checked: 2024/7/12 by [mint73](https://github.com/mint73)

0 commit comments

Comments
 (0)