Python プログラミングの基本(Python Tutor,VisuAlgo を使用)(スライド資料とプログラム例)(全9回)

教材の利用条件: クリエイティブコモンズ 表示-非営利-継承 4.0 国際ライセンス(CC BY-NC-SA 4.0)に基づき、著作者表示・非営利目的・同一ライセンスでの再配布を条件として自由に利用可能である。

オンラインのPython Tutor (http://pythontutor.com)VisuAlgo (https://visualgo.net/ja) を使用

目次

  1. po-1. プログラミング入門 [PDF], [パワーポイント], [スライド HTML]

    トピックス:GDB online, Java プログラム実行

  2. po-2. Python プログラミングの基本 [PDF], [パワーポイント], [スライド HTML]

    トピックス:計算, 変数, 代入, キーボードからの読み取り, 表示

  3. po-3. 式の抽象化と関数 [PDF], [パワーポイント], [スライド HTML]

    トピックス:条件分岐, if, else, 比較演算

  4. po-4. 条件分岐,ステップ実行 [PDF], [パワーポイント], [スライド HTML]
  5. po-5. リスト,辞書 [PDF], [パワーポイント], [スライド HTML]
  6. po-6. 繰り返し実行(ループ),ステップ実行 [PDF], [パワーポイント], [スライド HTML]
  7. po-7. モジュール,標準ライブラリ,算法(アルゴリズム) [PDF], [パワーポイント], [スライド HTML]
  8. po-8. クラス,メソッド,オブジェクト生成 [PDF], [パワーポイント], [スライド HTML]
  9. po-9. クラス階層,継承 [PDF], [パワーポイント], [HTML]

関連するオンラインサービス

外部ページへのリンク(Python 関連)

サイト内の関連ページ

【Python のインストール】

  • Windows での Python 3.10,関連パッケージ,Python 開発環境のインストール: 別ページ »で説明している.
  • Windows での Python とディープラーニング環境(NVIDIA CUDA, NVIDIA cuDNN, Python, TensorFlow, PyTorch その他)のインストール: 別ページで説明
  • Ubuntu での Python3 開発用ファイル,pip, setuptools, venv のインストール,Python 開発環境,Python コンソールのインストール: 別ページ »で説明している.

1. プログラミング入門

資料:po-1. プログラミング入門 [PDF], [パワーポイント], [スライド HTML]

トピックス:Python, プログラミング, Python Tutur, Python Tutor での Python プログラム実行, プログラムによる問題解決, 計算誤差, さまざまなプログラミング言語

2. Python プログラミングの基本

資料:po-2. Python プログラミングの基本 [PDF], [パワーポイント], [スライド HTML]

トピックス:Python, プログラミング, 式, 変数, オブジェクト, メソッド, 引数, 代入, データの種類, 制御, 条件分岐, 繰り返し, コードコンバット(Code Combat)

3. 式の抽象化と関数

資料:po-3. 式の抽象化と関数 [PDF], [パワーポイント], [スライド HTML]

トピックス:Python, プログラミング, Python Tutor, 式, 変数, 式の抽象化, 関数, 関数定義, def, 関数呼び出し

4. 条件分岐,ステップ実行

資料:po-4. 条件分岐,ステップ実行 [PDF], [パワーポイント], [スライド HTML]

トピックス:Python, プログラミング, Python Tutor, 条件分岐, if, else, ステップ実行

5. リスト,辞書

資料:po-5. リスト,辞書 [PDF], [パワーポイント], [スライド HTML]

トピックス:Python, プログラミング, Python Tutor,リスト, 辞書

6. 繰り返し実行(ループ),ステップ実行

資料:po-6. 繰り返し実行(ループ),ステップ実行 [PDF], [パワーポイント], [スライド HTML]

トピックス:Python, プログラミング, Python Tutor, 繰り返し, for, in, ステップ実行

7. モジュール,標準ライブラリ,算法(アルゴリズム)

資料:po-7. モジュール,標準ライブラリ,算法(アルゴリズム) [PDF], [パワーポイント], [スライド HTML]

トピックス:Python, プログラミング, Python Tutor, モジュール, インポート, import, サブモジュール, パッケージ, 標準ライブラリ, 算法, アルゴリズム

8. クラス,メソッド,オブジェクト生成

資料:po-8. クラス,メソッド,オブジェクト生成 [PDF], [パワーポイント], [スライド HTML]

トピックス:Python, プログラミング, Python Tutor, クラス, class, def, __init__, オブジェクト, クラス定義, メソッド, self, オブジェクト生成, メソッドアクセス, 属性アクセス

資料中のソースコード 8-2

class Ball:
    def __init__(self, x, y, r, color):
        self.x = x
        self.y = y
        self.r = r
        self.color = color
    def printout(self):
        print(self.x, self.y, self.r, self.color)

a = Ball(8, 10, 1, "blue")
b = Ball(2, 4, 3, "green")
a.printout()
b.printout()

資料中のソースコード 8-3

class Ball:
    def __init__(self, x, y, r, color):
        self.x = x
        self.y = y
        self.r = r
        self.color = color
    def printout(self):
        print(self.x, self.y, self.r, self.color)
    def dist(self):
        return self.x + self.y

a = Ball(8, 10, 1, "blue")
b = Ball(2, 4, 3, "green")
a.printout()
b.printout()
print(a.dist())

資料中のソースコード 8-4

class Ball:
    def __init__(self, x, y, r, color):
        self.x = x
        self.y = y
        self.r = r
        self.color = color
    def printout(self):
        print(self.x, self.y, self.r, self.color)
    def dist(self):
        return self.x + self.y
    def move(self, xx, yy):
        self.x = self.x + xx;
        self.y = self.y + yy;
        
a = Ball(8, 10, 1, "blue")
b = Ball(2, 4, 3, "green")
a.move(5, 5)
b.move(10, 10)
a.printout()
b.printout()
print(a.dist())

資料中のソースコード 8-4

class Ball:
    def __init__(self, x, y, r, color):
        self.x = x
        self.y = y
        self.r = r
        self.color = color
    def printout(self):
        print(self.x, self.y, self.r, self.color)
    def dist(self):
        return self.x + self.y
    def move(self, xx, yy):
        self.x = self.x + xx;
        self.y = self.y + yy;
    def right(self, xx):
        self.move(xx, 0)
    def left(self, xx):
        self.move(-xx, 0)
        
a = Ball(8, 10, 1, "blue")
b = Ball(2, 4, 3, "green")
a.move(5, 5)
b.move(10, 10)
a.right(5)
b.left(10)
a.printout()
b.printout()
print(a.dist())

9. クラス階層,継承

資料:po-9. クラス階層,継承 [PDF], [パワーポイント], [HTML]

トピックス:Python, プログラミング, Python Tutor, クラス定義, メソッド, クラス階層, 継承, super, dir

資料中のソースコード

class Point:
    def __init__(self, x, y, color):
        self.x = x
        self.y = y
        self.color = color
    def printout(self):
        print(self.x, self.y, self.color)

class Ball(Point):
    def __init__(self, x, y, r, color):
        super(Ball, self).__init__(x, y, color)
        self.r = r
    def printout(self):
        print(self.x, self.y, self.r, self.color)

p = Point(1, 2, "red")
p.printout()       
a = Ball(8, 10, 1, "blue")
b = Ball(2, 4, 3, "green")
a.printout()
b.printout()
class Point:
    def __init__(self, x, y, color):
        self.x = x
        self.y = y
        self.color = color
    def printout(self):
        print(self.x, self.y, self.color)
    def reset(self):
        self.x = 0
        self.y = 0

class Ball(Point):
    def __init__(self, x, y, r, color):
        super(Ball, self).__init__(x, y, color)
        self.r = r
    def printout(self):
        print(self.x, self.y, self.r, self.color)

p = Point(1, 2, "red")
p.printout()       
a = Ball(8, 10, 1, "blue")
b = Ball(2, 4, 3, "green")
a.reset()
b.reset()
a.printout()
b.printout()

関連動画