---
title: pf-2. 式，変数
tags:  #python #google colaboratory #式 #変数 #print #金子邦彦研究室  
author: [kunihikokaneko](https://www.docswell.com/user/6674398749)
site: [Docswell](https://www.docswell.com/)
thumbnail: https://bcdn.docswell.com/page/YE9Y646ZJ3.jpg?width=480
description: トピックス：Python, Google Colaboratory, 式, 変数, print  Python 入門（Google Colaboratory を使用）（全８回） https://www.kkaneko.jp/pro/pf/index.html  金子邦彦研究室ホームページ https://www.kkaneko.jp/index.html
published: January 29, 23
canonical: https://www.docswell.com/s/6674398749/529JNZ-2023-01-29-133859
---
# Page. 1

![Page Image](https://bcdn.docswell.com/page/YE9Y646ZJ3.jpg)

pf-2. 式，変数
（Python 入門，Google Colaboratory を使用）
（全８回）
URL: https://www.kkaneko.jp/pro/pf/index.html
金子邦彦
1


# Page. 2

![Page Image](https://bcdn.docswell.com/page/GE86ZQPY7D.jpg)

Python の変数
• 変数：名前の付いたオブジェクトには，変数，関
数などがある（変数や関数は，数学の変数や関数
とは違う意味）
• 変数は， 「値をコンピュータに覚えさせておくも
の」として使うことができる
変数には，値を代入できる
2


# Page. 3

![Page Image](https://bcdn.docswell.com/page/LEL9DX19JR.jpg)

式
• 式から値が求まる（コンピュータを使って，計算
などができる）
• 式は変数を含むことができる
3


# Page. 4

![Page Image](https://bcdn.docswell.com/page/4JMZPLWVEW.jpg)

まとめ
• 変数には，名前と値がある．
• 式から値が求まる
4


# Page. 5

![Page Image](https://bcdn.docswell.com/page/PJR61KYW79.jpg)

演習
資料：6 ～ 10
【トピックス】
• 変数
•式
5


# Page. 6

![Page Image](https://bcdn.docswell.com/page/PEXMYLGV7X.jpg)

① Google Colaboratory のWebページを開く
https://colab.research.google.com
6


# Page. 7

![Page Image](https://bcdn.docswell.com/page/3EKG3L45JD.jpg)

② 「ファイル」で，「ノートブックを新規作成」を選ぶ
③ Google アカウントでのログインが求められたときはログ
インする
7


# Page. 8

![Page Image](https://bcdn.docswell.com/page/L73NG3L175.jpg)

④ コードセルを新規作成し，Python プログラムを入れる
print(100 * 200)
すべて半角文字
「*」は掛け算の記号
⑤ 実行結果を確認
8


# Page. 9

![Page Image](https://bcdn.docswell.com/page/87DW14NKJG.jpg)

底辺が２．５で，高さが５のとき，
三角形の面積は，面積： ６．２５
⑥コードセルを新規作成し，Python プログラムを入れる
teihen = 2.5
すべて半角文字
takasa = 5
print(teihen * takasa / 2)
⑦ 実行結果を確認
結果の
「6.25」が表示
されるので確認
9


# Page. 10

![Page Image](https://bcdn.docswell.com/page/VJP9QM53E8.jpg)

円周率を 3.14 とする．半径が 3 の円
円の面積は： 28.26
⑧ コードセルを新規作成し，Python プログラムを入れる
r=3
すべて半角文字
print(r * r * 3.14)
⑨ 実行結果を確認
結果の
「28.26」が表示
されるので確認
10


# Page. 11

![Page Image](https://bcdn.docswell.com/page/2EVM59PNEQ.jpg)

Python 関連ページ
• Python まとめページ
https://www.kkaneko.jp/tools/man/python.html
• Python プログラミングの基本
Python Tutor, VisuAlgo, Code Combat を使用
https://www.kkaneko.jp/pro/po/index.html
• Python プログラム例
https://www.kkaneko.jp/pro/python/index.html
• 人工知能の実行（Google Colaboratory を使用）
https://www.kkaneko.jp/ai/ni/index.html
• 人工知能の実行（Python を使用）（Windows 上）
https://www.kkaneko.jp/ai/deepim/index.html
11


