Practical Programming
An Introduction to Computer Science
Using Python 3
(Pragmatic Programmers)
(Pragmatic Bookshelf)
Paul Gries (著) Jennifer Campbell (著)
Jason Montojo (著) Lynn Beighley (編集)
開発環境
- OS X Mavericks - Apple(OS)
- Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
- Python 3.4 (プログラミング言語)
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) 10.を解いてみる。
5.6(Exercises) 10.
- It's acidic!
- It's acidic!'
コード(BBEdit)
sample9.py
#!/usr/bin/env python3 #-*- coding: utf-8 -*- ph = float(input('Enter the ph level: ')) if ph < 7.0: print("it's acidic!") if ph < 4.0: print("It's a strong acid!")
入出力結果(Terminal, IPython)
$ ./sample10.py Enter the ph level: 1 it's acidic! It's a strong acid! $
0 コメント:
コメントを投稿