公開:2025-05-19、更新:2025-05-19
7-4「range関数」 7ページ
マンガ

7:終わり
コンテンツ紹介
テキスト原稿
# 7p
__1__
猫野:
単純に数値を使いたい
ときはrangeが便利だ
最後に少しプログラムを
書いてみよう
__2__
```py
for i in range(10):
print(f'{i} * {i} = {i * i}')
```
出力
0 * 0 = 0
1 * 1 = 1
2 * 2 = 4
3 * 3 = 9
4 * 4 = 16
5 * 5 = 25
6 * 6 = 36
7 * 7 = 49
8 * 8 = 64
9 * 9 = 81
---
__3__
```py
import matplotlib.pyplot
x = []
y = []
for i in range(10):
x.append(i)
y.append(i * i)
matplotlib.pyplot.plot(x, y)
matplotlib.pyplot.show()
```
__4__
グラフを表示
(グラフ)