Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
第3回「Python入門(2)」2023年11月13日資料
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
sasasa
November 13, 2023
110
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
第3回「Python入門(2)」2023年11月13日資料
sasasa
November 13, 2023
More Decks by sasasa
See All by sasasa
第2回「Python入門(1)」2023年11月6日資料
hsasasasa
0
130
Featured
See All Featured
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
510
Skip the Path - Find Your Career Trail
mkilby
1
240
Git: the NoSQL Database
bkeepers
PRO
432
67k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
420
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
Tell your own story through comics
letsgokoyo
1
1.1k
ラッコキーワード サービス紹介資料
rakko
1
5.1M
Prompt Engineering for Job Search
mfonobong
0
460
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
390
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
550
The Curse of the Amulet
leimatthew05
3
15k
How to Ace a Technical Interview
jacobian
280
24k
Transcript
旭川高専デジタル人材育成講座 『Python入門(2)』 2023年11月13日(月) 笹岡久行(ささおか ひさゆき) 旭川工業高等専門学校 電気情報工学科 (ご注意)本資料は当該講座以外では個人の学習目的での利用可
前回の振り返りから
None
Pythonの教材 とても多くの無料で学べる教材があります.例えば, 1. 公式サイト https://www.python.org/ 2. 東京大学「Pythonプログラミング入門」 https://utokyo-ipp.github.io/ 3. 京都大学「プログラミング演習Python2021」https://repository.kulib.kyoto-
u.ac.jp/dspace/bitstream/2433/265459/1/Version2021_10_08_01.pdf 4. 東京工業大学「Python早見帳」https://chokkan.github.io/python/index.html 5. 筑波大学(三谷先生) https://mitani.cs.tsukuba.ac.jp/book_support/python/python_slides.pdf 6. さくらインターネット株式会社「初学者向けTellus学習コース」 https://tellusxdp.github.io/start-python-with-tellus/index.html など
「Python」を使ってみる!
Google「Colaboratory」https://colab.research.google.com/ WebブラウザでPythonのプログラミングが可能 もし,Googleのアカウントがあるとオンラインで成果の保存も可能
問題1「0.1 + 0.1 + 0.1」の答えは? セル(四角の中)へ式を入力し,「Enter」キーを押す. IT用語辞典(https://e-words.jp/)から引用
2次方程式を解いてみる!
Pythonに2次方程式を解いてもらう • セルの中に入力し,実行 ◦ 「#」はコメントなので,入力の必要はありません。 「import」や「if」はPythonの命令です。 今回はそのまま入力してください。
答え
(余談2) Pythonの「if文」 (ご参考)「とほほのPython入門」 https://www.tohoho-web.com/python/control.html#if
(余談2) Pythonの「if文」(続き) (ご参考)「とほほのPython入門」https://www.tohoho-web.com/python/control.html#if
簡単なグラフを書いてみよう!
グラフを書いてみよう!(1) 『 y = x 』のグラフ ↓ 行番号は無視してください。 3行目で「y =
x」の「x」の部分を定義 (難)5行目 xが取る範囲を定義 (難)6行目 グラフを描く範囲を定義 (難)7行目 x, yの座標に点をプロット (難)8行目 補助線(灰色の線)を表示
グラフを書いてみよう!(2) 『 y = x 2』のグラフ ↓ 行番号は無視してください。 3行目で「y =
x2」の「 x2 」の部分を定義 (Pythonでは「**」で◯乗を意味します。)
今回の内容
数値の平均を求めてみる.
例えば,テストの平均点 Aさんは90点,Bさんは97点,Cさんは70点でした. この3名のテストの点の平均は? ( 90 + 97 + 70 )
÷ 3 = 85.6666...
では,100個の自然数の平均では? 『 ( 1個目の数 + 2個目の数 + ... ) ÷
100 』
(余談) 適当な数(乱数)を100個作る
(余談2) Pythonのリスト (ご参考)「とほほのPython入門」 https://www.tohoho-web.com/python/list.html Pythonでは基本的な変数(整数,実数,文字,文字列)以外にもデータの束を 扱う型も用意されている.その一つがリスト
(余談2) Pythonのリスト(続き) (ご参考)「@IT」ホームページからの抜粋 https://atmarkit.itmedia.co.jp/ait/articles/1905/31/news015.html
(余談2) Pythonのリスト(続き) (ご参考)「Python公式ドキュメント」の抜粋 https://docs.python.org/ja/3/tutorial/datastructures.html
(余談) 適当な数(乱数)を100個作る(結果)
(余談の余談)繰り返し「while文」 (ご参考)「とほほのPython入門」https://www.tohoho-web.com/python/control.html
100個の自然数の平均(Pythonでは?) ( 1個目の数 + 2個目の数 + ... ) ÷ 100
(余談の余談)繰り返し「for 文」 (ご参考)「とほほのPython入門」https://www.tohoho-web.com/python/control.html
100個の自然数の平均 ( 1個目の数 + 2個目の数 + ... ) ÷ 100
(余談)統計に関わるライブラリの一つ 公式ドキュメント https://docs.python.org/ja/3/library/statistics.html
問題 「0~1000」までの整数の乱数を1000個 発生し,平均を求める.
解答例
CSVファイルを読み込み,平均を求める
ライブラリ「Pandas」とは • 公式ホームページ https://pandas.pydata.org/
CSVファイルとは? 例えば,
Colaboratryでも使える • まず,アップロード • ダブルクリックで閲覧
Pandasを利用して,CSVファイルを読み込み
Pandasのread_csvとは • 公式ドキュメント https://pandas.pydata.org/docs/reference/api/pandas.read_csv.html • できることが多すぎて難しいです. • 簡単には指定したCSVファイルを読み込み,データフレームに格納する.
(余談)Pandasのデータフレームとは Googleの検索では,
Pandasの関数「describe」を利用してみる • 公式ドキュメント https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.describe.html
要約統計量 • 引用元 https://deepage.net/features/pandas-describe.html
問題 気象庁の気象データを解析 • 気象庁ホームページ https://www.data.jma.go.jp/gmd/risk/obsdl/index.php • お好きな町のお好きなデータで大丈夫です. • 旭川市の2022年1月~12月(365日)の一日の平均気温
解答例 • 別途,CSVファイルを用意 1.CSVファイルの読み込み 2.要約統計量の計算と表示
まとめ • Pythonの制御構造 ◦ if文,for文,while文 など • 「リスト」について • 「平均」を求める
◦ for文を利用して自分で計算 ◦ 関数で求める ◦ Pandasの利用 • CSVファイルの解析 ◦ 要約統計量を求める
ご参考 • 九州大学 Python教材(今回の範囲) https://deepage.net/features/pandas-describe.html