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
Python2019-1
Search
sk
May 16, 2019
Education
98
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Python2019-1
sk
May 16, 2019
More Decks by sk
See All by sk
Python講座演習4.pdf
shuy_k3
0
81
Python講座第3回.pdf
shuy_k3
0
70
Python2019-2
shuy_k3
0
75
Other Decks in Education
See All in Education
Réunion des directrices et directeurs des écoles de la circonscription de Jonzac - 31 août 2026
fmarot
0
120
医師がスタッフに AI を教えるとき、どんな内容を話しているか
osawaux
1
120
学生のうちに考えておきたい信頼の話
suisan
1
770
Enterprise UI, v2
stevekinney
0
220
Del ojo entrenado a la visión computacional: evaluación de la severidad de enfermedades
emdelponte
0
120
ちいかわを読め
uchi8977
1
330
批判的応用言語学ワークショップ(2026-08-12 お茶の⽔⼥⼦⼤学)
terasawat
0
190
0526
cbtlibrary
0
270
!コスパよくインターンに受かる方法!
ruribou
1
350
2026年度春学期 統計学 第15回 分布についての仮説を検証する ― 仮説検定(2) (2026. 7. 9)
akiraasano
PRO
0
130
Antigravityを使ってGeminiAPI(NanobananaPro)と連携して挿絵メーカーを作った
yoshimura_datam
0
210
輻射安全管理系統2.0暨輻防e++學園平台說明會
aecrp
0
2k
Featured
See All Featured
The Language of Interfaces
destraynor
162
27k
Facilitating Awesome Meetings
lara
57
7.1k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
540
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Mobile First: as difficult as doing things right
swwweet
225
10k
Site-Speed That Sticks
csswizardry
13
1.5k
Navigating Team Friction
lara
192
16k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
290
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
4
610
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
450
Transcript
Python講座 ~第一回~ 計算技術研究会(K3) IN2019
講座の資料について 今回は時間が足りなかったのでPowerPointで。 次回からはもう少し凝ります。。。 講座終了前後に公開します。 何か良い公開方法があれば教えて下さい
Pythonについて Pythonとは…インタープリタ型言語 →即入力、即実行! 文法がシンプル!(らしい) 分かりやすい!(らしい) ★非専門家並みの 感想
★楽しいよ!
開発環境 ・IDLE: 初心者向け 基本的に授業程度ならこれでどうにかなる ・Visual Studio Code(VScode): 多数の言語に対応 追加機能を増やせるので便利(僕はよくわかってないです) ・PyCharm:
Python特化型 ★プログラマー 感あるよね
コードを書くにあたって Python講座用のフォルダを作りましょう →→演習ごとにファイルを保存、管理しましょう
ここからPythonの話~~
基本的な概念 関数: もともと機能(動作)が決まっているもの 名前が決まっている(print, input, importなど……) 変数: 文字や数字を格納するもの
自由に名前を付けて宣言!
Input関数 I = input()のように書くと、コンソールで数字や文字を入力して 変数 I に格納することができる。 入力が必要なプログラムで使います。
k = input() とか
Print関数とFormat print() と書けば実行時に()内部に応じた結果が表示される。 文字列(“”)の中に変数、値を入れたいときはformat →二種類の書き方 ・print( “x =
{} ” . format(x) ) ・print( f ”x = {x} ” )
代入 変数に文字、値を格納 = 代入 変数 a に 123
を格納 → > a = 123 変数は上書きされていく > a = 123 : a は 123 > a = 0 : a は0(123として利用できなくなる)
変数の型 型が複数存在する(int, float, char……) →型が同じもの同士じゃないと代入などで不具合が!! →文字列は文字列、値は値同士で! ・ int: 整数の型……
1, 2, 3, 4, 5….. ・float : 実数の型…… 1.0 や 2.51 ・sting: 文字列型…… “” , ‘’で囲われたものなど ・(char: 文字型)…… 一文字(a, b, x, y……) ★Integer ★Pythonに は無い。
変数の型 同じ型同士の足し算 int型(x=2、y=3) > x + y >
5 String型(x = “法政”、y = “university”) > x + y > “法政university”
変数の型 int + string ……?(x = 1、y = “年生”)
> x + y >error! print(x + y) >error! →→ formatを使おう!
変数の型 型変換:変数の型を変更できる! str()関数や int関数の()内に変数を入れる > x = “1” :
xは文字の ”1” > x = int(x) : xに新たなx(整数型)が上書きされる > x = str(x) : 同様にxが新たなx(文字列)になった ★string ↕↕ ★integer
演算 いろんな演算が存在 ・四則演算 ( + - * / )
・余りの計算 ( % ) →c = x % y : 変数 c は x を y で割った余り ★*と / に注意 ★意外と重要!
演算(発展?) x = x + 1 →これはプログラム界では正しい記述です。 さっきやったように、変数を上書きして更新したいときに使う x
= x + 1 → x += 1 y = y – 5 → y -= 5 s = s * 9 → s *= 9 v = v / 10 → v /=10 h = h % 4 → h %= 4 ★イコールは右
演習1 (1)Inputで入力した整数の値を 2倍 にして出力 (2)inputで入力した実数の値を 3倍 にして出力
(3)inputで2つの整数値a,bを入力して 「aをbで割った余りは~」という文字列を出力 ★input() ★print() ★format ★int ★float ★a, bは自由 ★%を使おう
条件分岐 条件に応じてプログラムの動作を変えられる。 →RPGゲームの選択肢とか プログラムが上から順に実行されることに注意していこう
条件分岐 最初の分岐はIf(条件式):を使用 > If (条件式): > 動作を記述していく (一段ずらしていく) ・If文の一つのまとまり:ブロック
分岐するときはelif (条件式): 条件に沿わない残りのすべてはelse:に放りこむ。 If文に入ったらelif、elseは実行されない!他も同様 ★コロン(:) ★else+ifの意味
演習2 (1)整数x, yにおいて xがyよりも小さかったらxとyの値 を入れ替えて、xとyを出力 (2) 整数x, yにおいて
yが偶数ならxを2倍して、yが奇数 ならxを2で割って、xを出力
演習3(終わった人) (1)適当な数値のリストに対して最大値と最小値を出力 (2)適当な数値のリストに対して最大値と最小値のイン デックス(番目)を出力 (3)初期値をinputで受け取った整数xを、xの値が20より 大きくなるまで2倍しながらリストに追加していって、 そのリストを出力
None