2014年8月3日日曜日

開発環境

Practical Programming: An Introduction to Computer Science Using Python 3 (Pragmatic Programmers) (Paul Gries (著)、Jennifer Campbell (著)、Jason Montojo (著)、Lynn Beighley (編集)、Pragmatic Bookshelf)のChapter 5(Making Choices)、5.6(Exercises) 9.を解いてみる。

5.6(Exercises) 9.

コード(BBEdit)

sample9.py

#!/usr/bin/env python3
#-*- coding: utf-8 -*-

for ph in range(10):
    if ph < 3.0:
        print(ph, "is VERY acidic! Be careful.")
    elif ph < 7.0:
        print(ph, "is acidic.")

入出力結果(Terminal, IPython)

$ ./sample9.py
0 is VERY acidic! Be careful.
1 is VERY acidic! Be careful.
2 is VERY acidic! Be careful.
3 is acidic.
4 is acidic.
5 is acidic.
6 is acidic.
$

0 コメント:

コメントを投稿