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

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

大学で使用した自作の資料等を,手直しの上公開している. クリエイティブ・コモンズ BY NC SA.

オンラインの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 のインストール】

1. プログラミング入門

SlideShare: https://www.slideshare.net/kunihikokaneko1/po1-255586220

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

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

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

SlideShare: https://www.slideshare.net/kunihikokaneko1/po2-python-255586235

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

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

3. 式の抽象化と関数

SlideShare: https://www.slideshare.net/kunihikokaneko1/po3-255586242

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

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

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

SlideShare: https://www.slideshare.net/kunihikokaneko1/po4-255586245

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

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

5. リスト,辞書

SlideShare: https://www.slideshare.net/kunihikokaneko1/po5-255586250

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

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

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

SlideShare: https://www.slideshare.net/kunihikokaneko1/po6-255586252

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

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

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

SlideShare: https://www.slideshare.net/kunihikokaneko1/po7-255586258

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

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

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

SlideShare: https://www.slideshare.net/kunihikokaneko1/po8-255586261

資料: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. クラス階層,継承

SlideShare: https://www.slideshare.net/kunihikokaneko1/po9-255586266

資料: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()

関連動画