Upgrade to Pro — share decks privately, control downloads, hide ads and more …

はじめてのPython(2025ver)

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
Avatar for yuuuka yuuuka
April 27, 2025

 はじめてのPython(2025ver)

Avatar for yuuuka

yuuuka

April 27, 2025
Tweet

More Decks by yuuuka

Other Decks in Programming

Transcript

  1. 本日のハンズオンの流れ • Pythonをインストールしてみよう • ターミナル/コマンドプロンプトを使ってみよう • ターミナル/コマンドプロンプト上でPythonコードを動かしてみよう • Pythonの型 •

    Pythonの文法 • Pythonの関数 • Pythonのモジュール • VSCodeでPythonコードを動かしてみよう • モジュールを使って画像を表示してみよう • モジュールを使って自分が生後何日か計算してみよう
  2. それぞれ入力してみよう! >>> a = 'abc' >>> b = 'aaa123' >>>

    c = 123 >>> d = True >>> e = [1, 2, 3] >>> f = ['a', 'b', 'c']
  3. 基本的なPythonの型 変数の型 格納される値の種類 例 int 整数 1,100000, 123456789 float 少数

    1.1, 10000.1 str 文字列 ‘a’、’aaa’、’A’、’ABC’、’ あいうえお’ bool trueもしくはfalseの真 偽値 True:1, False:0 list 整数や文字列などを複 数格納できる [1, 2, 3],[‘a’, ‘b’, ‘c’]
  4. ステップ3. コードを書いてみよう! 作成したshow_image.pyファイルを開き、以下のコードを 書いてみましょう import io import requests from PIL

    import Image response = requests.get("https://www.python.jp/logo.png") img = Image.open(io.BytesIO(response.content)) img.show()
  5. ステップ2. コードを書いてみよう! 作成したcalculate_age_in_days.pyファイルを開き、以 下のコードを書いてみましょう from datetime import datetime birthday =

    datetime(year=2014, month=10, day=25) print(birthday) today = datetime.now() print(today.year, today.month, today.day) diff_days = abs(birthday - today) print(diff_days)
  6. ステップ3. コードを書いてみよう! … data = np.random.randn(100, 4) columns = ['A',

    'B', 'C', 'D'] df = pd.DataFrame(data, columns=columns) print("First few rows of the DataFrame:") print(df.head())
  7. ステップ3. コードを書いてみよう! … mean_values = df.mean() print("\nMean values of each

    column:") print(mean_values) plt.figure(figsize=(10, 6)) plt.plot(df['A'], label='Column A') plt.plot(df['B'], label='Column B') plt.show()