開発環境
- OS X Lion - Apple(OS)
- TextWrangler(Text Editor) (BBEditの無料機能制限版、light版)
- Script言語: Python
『初めてのPython 第3版』(Mark Lutz 著、夏目 大 訳、オライリー・ジャパン、2009年、ISBN978-4-87311-393-7) のII部(ビルトインオブジェクト)の5章(数値)の練習問題5を解いてみる。
その他参考書籍
5.
浮動小数点数型(float型)になる。
コード(TextWrangler)
sample.py
#!/usr/bin/env python #-*- coding: utf-8 -*- a = 1 b = 2.0 c = 3 total = a + b + c for x in [a,b,c,total]: print(x,type(x))
入出力結果(Terminal)
$ ./sample.py 1 <class 'int'> 2.0 <class 'float'> 3 <class 'int'> 6.0 <class 'float'> $
0 コメント:
コメントを投稿