開発環境
- OS X Lion - Apple(OS)
- BBEdit - Bare Bones Software, Inc.(Text Editor)
- Script言語: Python
『初めてのPython 第3版』(Mark Lutz 著、夏目 大 訳、オライリー・ジャパン、2009年、ISBN978-4-87311-393-7) のII部(ビルトインオブジェクト)の5章(数値)練習問題を解いてみる。
その他参考書籍
練習問題.
コード(BBEdit)
sample.py
#!/usr/bin/env python3.3 #-*- coding: utf-8 -*- print("Hello, module world!")
入出力結果(Terminal)
$ ./sample.py 14 10 14 0.0 1.0 1.4142135623730951 1.7320508075688772 2.0 2.23606797749979 2.449489742783178 2.6457513110645907 2.8284271247461903 3.0 <class 'float'>1 1 2 <class 'float'>0o12 0xa 10 10 $
ちなみにJavaScriptの場合。
コード(BBEdit)
var result = ""; for(var i = 0; i < 10; i++){ result += "√" + i + " = " + Math.sqrt(i) + "\n"; } result += Math.floor(1.9) + "\n" + Math.round(1.4) + "\n" + Math.round(1.5) + "\n" + (10).toString(8) + "\n" + (10).toString(16) + "\n" + parseInt((10).toString(8), 8) + "\n" + parseInt((10).toString(16), 16); $('#pre0').text(result);
0 コメント:
コメントを投稿