はじめに
登場人物
青山 千尋(あおやま ちひろ)先生:
学校の先生でプログラミングに詳しい人物。絵里と優奈が通う学校のプログラミング部の顧問。
藤崎 絵里(ふじさき えり):
青山先生が顧問をしているプログラミング部の部員。プログラミングは未経験。
朝倉 優奈(あさくら ゆな):
青山先生が顧問をしているプログラミング部の部員。絵里の親友。プログラミングは未経験。
月島 結翔(つきしま ゆいと)ナレーター:
本ブログでナレーションを担当。普段は、地元のTV番組やラジオ番組でナレーターとして活動。
第2章 Pythonって何?
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-28-00.53.03-Create-an-illustration-of-a-young-male-teacher-in-an-anime-style.-He-has-a-professional-but-friendly-demeanor-with-short-neatly-styled-hair-and-glas-150x150.webp)
この章ではPythonがどんなプログラミング言語なのか一緒に学んでいきましょう。
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.41.35-Create-an-illustration-of-a-young-girl-with-black-short-hair-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp--150x150.webp)
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.41.35-Create-an-illustration-of-a-young-girl-with-black-short-hair-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp--150x150.webp)
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.41.35-Create-an-illustration-of-a-young-girl-with-black-short-hair-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp--150x150.webp)
ちひろ先生、Pythonについて教えてください!
![](https://botdevstudio.com/wp-content/uploads/2024/02/青山先生-150x150.png)
![](https://botdevstudio.com/wp-content/uploads/2024/02/青山先生-150x150.png)
![](https://botdevstudio.com/wp-content/uploads/2024/02/青山先生-150x150.png)
わかったわ。Pythonは、私たちの身の回りの多くで活用されているプログラミング言語よ。例えば、GoogleやNetflixなどがそうよ。
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.36.07-Create-an-illustration-of-a-young-girl-with-a-ponytail-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp-look--150x150.webp)
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.36.07-Create-an-illustration-of-a-young-girl-with-a-ponytail-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp-look--150x150.webp)
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.36.07-Create-an-illustration-of-a-young-girl-with-a-ponytail-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp-look--150x150.webp)
へえ、そんなに使われているんですか?Pythonってどんな特徴があるんですか?
![](https://botdevstudio.com/wp-content/uploads/2024/02/青山先生-150x150.png)
![](https://botdevstudio.com/wp-content/uploads/2024/02/青山先生-150x150.png)
![](https://botdevstudio.com/wp-content/uploads/2024/02/青山先生-150x150.png)
ええ、Pythonは非常に読みやすく、初心者にも親しみやすい言語なの。プログラミングは、コンピュータに対するレシピを書くようなもの。Pythonは、そのレシピを書くための言葉の一つなのよ。
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.41.35-Create-an-illustration-of-a-young-girl-with-black-short-hair-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp--150x150.webp)
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.41.35-Create-an-illustration-of-a-young-girl-with-black-short-hair-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp--150x150.webp)
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.41.35-Create-an-illustration-of-a-young-girl-with-black-short-hair-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp--150x150.webp)
それはすごいですね。でも、たくさんのプログラミング言語があるのにPythonがなぜそんなに人気なのか気になります。
![](https://botdevstudio.com/wp-content/uploads/2024/02/青山先生-150x150.png)
![](https://botdevstudio.com/wp-content/uploads/2024/02/青山先生-150x150.png)
![](https://botdevstudio.com/wp-content/uploads/2024/02/青山先生-150x150.png)
その人気の秘密は、Pythonの汎用性にあるの。Web開発からデータ分析、機械学習、さらにはゲーム開発まで、様々なことに使えるのよ。そしてね、Pythonはオブジェクト指向プログラミング言語としても特徴づけられているわ。
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.36.07-Create-an-illustration-of-a-young-girl-with-a-ponytail-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp-look--150x150.webp)
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.36.07-Create-an-illustration-of-a-young-girl-with-a-ponytail-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp-look--150x150.webp)
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.36.07-Create-an-illustration-of-a-young-girl-with-a-ponytail-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp-look--150x150.webp)
オブジェクト指向って、ちょっと聞いただけで難しそうですね…。
![](https://botdevstudio.com/wp-content/uploads/2024/02/青山先生-150x150.png)
![](https://botdevstudio.com/wp-content/uploads/2024/02/青山先生-150x150.png)
![](https://botdevstudio.com/wp-content/uploads/2024/02/青山先生-150x150.png)
確かに難しそうな言葉ね。オブジェクト指向とは、現実世界の物事を「オブジェクト」として扱う考え方なの。ここでいう「オブジェクト」とは、現実世界にある物や人、または考えなどを表すのよ。
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.36.07-Create-an-illustration-of-a-young-girl-with-a-ponytail-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp-look--150x150.webp)
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.36.07-Create-an-illustration-of-a-young-girl-with-a-ponytail-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp-look--150x150.webp)
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.36.07-Create-an-illustration-of-a-young-girl-with-a-ponytail-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp-look--150x150.webp)
やっぱり難しいです…
![](https://botdevstudio.com/wp-content/uploads/2024/02/青山先生-150x150.png)
![](https://botdevstudio.com/wp-content/uploads/2024/02/青山先生-150x150.png)
![](https://botdevstudio.com/wp-content/uploads/2024/02/青山先生-150x150.png)
そう感じるかもしれないけれど、オブジェクトを通して、「情報」と「できること」を一つにまとめることができるので慣れるとすごく便利なのよ。
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.41.35-Create-an-illustration-of-a-young-girl-with-black-short-hair-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp--150x150.webp)
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.41.35-Create-an-illustration-of-a-young-girl-with-black-short-hair-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp--150x150.webp)
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.41.35-Create-an-illustration-of-a-young-girl-with-black-short-hair-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp--150x150.webp)
ちひろ先生、オブジェクトについて、実例で教えてもらえますか?
![](https://botdevstudio.com/wp-content/uploads/2024/02/青山先生-150x150.png)
![](https://botdevstudio.com/wp-content/uploads/2024/02/青山先生-150x150.png)
![](https://botdevstudio.com/wp-content/uploads/2024/02/青山先生-150x150.png)
わかったわ。例えば、小学校のクラスを考えてみましょう。このクラスにはたくさんの生徒がいます。各生徒には、「名前」や「年齢」などの情報と「得意なこと(できること)」があるわよね。
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.41.35-Create-an-illustration-of-a-young-girl-with-black-short-hair-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp--150x150.webp)
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.41.35-Create-an-illustration-of-a-young-girl-with-black-short-hair-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp--150x150.webp)
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.41.35-Create-an-illustration-of-a-young-girl-with-black-short-hair-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp--150x150.webp)
はい、現実世界ではそうだと思います。
![](https://botdevstudio.com/wp-content/uploads/2024/02/青山先生-150x150.png)
![](https://botdevstudio.com/wp-content/uploads/2024/02/青山先生-150x150.png)
![](https://botdevstudio.com/wp-content/uploads/2024/02/青山先生-150x150.png)
これをオブジェクト指向に置き換えると、各生徒の「名前」や「年齢」などの情報がプロパティ、「得意なこと(できること)」がメソッドになるの。そして、各生徒のプロパティとメソッドを1つにまとめたものが「オブジェクト」ということよ。
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.36.07-Create-an-illustration-of-a-young-girl-with-a-ponytail-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp-look--150x150.webp)
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.36.07-Create-an-illustration-of-a-young-girl-with-a-ponytail-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp-look--150x150.webp)
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.36.07-Create-an-illustration-of-a-young-girl-with-a-ponytail-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp-look--150x150.webp)
以下のイラストのようなイメージになるのね。。。
![](https://botdevstudio.com/wp-content/uploads/2024/02/オブジェクトのイメージ画像-1.png)
![](https://botdevstudio.com/wp-content/uploads/2024/02/オブジェクトのイメージ画像-1.png)
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.36.07-Create-an-illustration-of-a-young-girl-with-a-ponytail-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp-look--150x150.webp)
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.36.07-Create-an-illustration-of-a-young-girl-with-a-ponytail-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp-look--150x150.webp)
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.36.07-Create-an-illustration-of-a-young-girl-with-a-ponytail-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp-look--150x150.webp)
なるほど、理解できました!オブジェクト指向だと、物事を簡単に扱えるようになるんですね!
![](https://botdevstudio.com/wp-content/uploads/2024/02/青山先生-150x150.png)
![](https://botdevstudio.com/wp-content/uploads/2024/02/青山先生-150x150.png)
![](https://botdevstudio.com/wp-content/uploads/2024/02/青山先生-150x150.png)
ええ、その通りよ。オブジェクト指向を使うと、複雑なプログラムも管理しやすくなるの。そして、Pythonの魅力の一つに、豊富な道具(ライブラリ)があることも忘れちゃいけないわ。
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.41.35-Create-an-illustration-of-a-young-girl-with-black-short-hair-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp--150x150.webp)
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.41.35-Create-an-illustration-of-a-young-girl-with-black-short-hair-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp--150x150.webp)
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.41.35-Create-an-illustration-of-a-young-girl-with-black-short-hair-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp--150x150.webp)
ライブラリとは、処理を簡単に実行できる「ツール」みたいなものですか?
![](https://botdevstudio.com/wp-content/uploads/2024/02/青山先生-150x150.png)
![](https://botdevstudio.com/wp-content/uploads/2024/02/青山先生-150x150.png)
![](https://botdevstudio.com/wp-content/uploads/2024/02/青山先生-150x150.png)
その通りよ。ほんの一例だけど、「ファイルを開く」や「音を出す」などのような処理を簡単に実行できるライブラリがPythonには豊富にあるのよ。
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.36.07-Create-an-illustration-of-a-young-girl-with-a-ponytail-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp-look--150x150.webp)
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.36.07-Create-an-illustration-of-a-young-girl-with-a-ponytail-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp-look--150x150.webp)
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.36.07-Create-an-illustration-of-a-young-girl-with-a-ponytail-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp-look--150x150.webp)
Pythonが便利なことはわかったのですが、Pythonを学ぶ最初の一歩は、どうしたらいいんですか?
![](https://botdevstudio.com/wp-content/uploads/2024/02/青山先生-150x150.png)
![](https://botdevstudio.com/wp-content/uploads/2024/02/青山先生-150x150.png)
![](https://botdevstudio.com/wp-content/uploads/2024/02/青山先生-150x150.png)
まずは、Pythonの基本的なルールを理解するところから始めましょう。そして、Pythonの実行環境を構築し、小さなプログラムから実際に書いて動かしてみるのがいいわね。
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.41.35-Create-an-illustration-of-a-young-girl-with-black-short-hair-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp--150x150.webp)
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.41.35-Create-an-illustration-of-a-young-girl-with-black-short-hair-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp--150x150.webp)
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.41.35-Create-an-illustration-of-a-young-girl-with-black-short-hair-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp--150x150.webp)
なんか、ワクワクしますね。早速試してみたいです。
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.36.07-Create-an-illustration-of-a-young-girl-with-a-ponytail-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp-look--150x150.webp)
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.36.07-Create-an-illustration-of-a-young-girl-with-a-ponytail-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp-look--150x150.webp)
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-26-22.36.07-Create-an-illustration-of-a-young-girl-with-a-ponytail-in-an-anime-style.-She-should-have-large-expressive-almond-shaped-eyes-to-give-a-sharp-look--150x150.webp)
私もです!
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-28-00.53.03-Create-an-illustration-of-a-young-male-teacher-in-an-anime-style.-He-has-a-professional-but-friendly-demeanor-with-short-neatly-styled-hair-and-glas-150x150.webp)
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-28-00.53.03-Create-an-illustration-of-a-young-male-teacher-in-an-anime-style.-He-has-a-professional-but-friendly-demeanor-with-short-neatly-styled-hair-and-glas-150x150.webp)
![](https://botdevstudio.com/wp-content/uploads/2024/02/DALL·E-2024-02-28-00.53.03-Create-an-illustration-of-a-young-male-teacher-in-an-anime-style.-He-has-a-professional-but-friendly-demeanor-with-short-neatly-styled-hair-and-glas-150x150.webp)
「本章のまとめ」を確認後、第3章へ進んでください。
本章のまとめ
- Pythonは読みやすく初心者に優しいプログラミング言語
- GoogleやNetflixなど広く使用されている
- Web開発、データ分析、機械学習、ゲーム開発に適用可能
- オブジェクト指向言語で、現実世界の物事をオブジェクトとして扱う
- 豊富なライブラリを提供、様々な処理を容易に実行