フリープログラミング
自由にプログラムを動かしてみよう
Pythonの基本的な操作や標準ライブラリが使えるので色々試してみてね
※無限ループや処理の重いプログラムについては途中で処理を止めるようにしています
出力結果
本サイトで確認ができている使用可能な標準ライブラリ一覧
| ライブラリ名 | インポート方法 | 簡単な説明 | 用途例 | プログラム例 |
|---|---|---|---|---|
| math | import math |
数学関数を提供 | 三角関数、対数、指数計算 | print(math.sqrt(16)) |
| random | import random |
乱数生成 | サイコロ、ランダム選択 | print(random.randint(1, 6)) |
| time | import time |
時間操作 | 一時停止、処理時間測定 | print(time.time()) |
| sys | import sys |
システム情報取得(一部) | Pythonバージョン取得 | print(sys.version) |
| itertools | import itertools |
イテレータ操作 | 順列・組み合わせ生成 | print(list(itertools.permutations([1,2,3]))) |
| operator | import operator |
高速演算関数 | 加算や乗算の簡略化 | print(operator.add(2,3)) |
| collections | import collections |
高度なデータ構造 | deque や Counter | counter = collections.Counter('hello') |
| re | import re |
正規表現の処理 | 文字列検索、置換 | print(re.findall(r'\d+', 'abc123')) |
| turtle | import turtle |
簡単な図形描画(本サイトでは表の下に表示) | 線や円を描画する | t = turtle.Turtle()
t.forward(100) |
turtle利用時の表示について
turtleを使うとこの下に描画されます
