開発環境
- OS X Mavericks - Apple(OS)
- BBEdit - Bare Bones Software, Inc., Emacs (Text Editor)
- Python (プログラミング言語)
初めてのコンピュータサイエンス(Jennifer Campbell、Paul Gries、Jason Montojo、Greg Wilson(著)長尾 高弘(翻訳))の2章(Python入門)の2.10(練習問題)、10を解いてみる。
10.
コード(BBEdit)
sample.py
#!/usr/bin/env python3.4 #-*- coding: utf-8 import math print('pow(3, 7) = {0}'.format(pow(3, 7))) print('3 ** 7 = {0}'.format(3 ** 7)) print('math.floor(34.7) = {}'.format(math.floor(34.7))) print('int(34.7) = {}'.format(int(34.7))) print('round(34.7) = {}'.format(round(34.7))) print('float(abs(-86)) = {0}'.format(float(abs(-86))))
入出力結果(Terminal)
$ ./sample.py pow(3, 7) = 2187 3 ** 7 = 2187 math.floor(34.7) = 34 int(34.7) = 34 round(34.7) = 35 float(abs(-86)) = 86.0 $
0 コメント:
コメントを投稿