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 7(Using Methods)、7.6(Exercises) 11-a, b, c, d, e, f.を解いてみる。
7.6(Exercises) 11-a, b, c, d, e, f.
コード(BBEdit)
sample11.py
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
s = 'boolean'
s1 = s.capitalize()
print(s, s1, sep='\n')
s = 'SO2 H2O'
i = s.find('2')
j = s.find('2', i + 1)
print(s, i, j, sep='\n')
print('Boolean'.islower())
s = 'MoNDaY'
s1 = s.lower()
s2 = s1.capitalize()
print(s, s1, s2, sep='\n')
s = ' Monday'
s1 = s.lstrip()
print(s, s1, sep='\n')
入出力結果(Terminal, IPython)
$ ./sample11.py boolean Boolean SO2 H2O 2 5 False MoNDaY monday Monday Monday Monday
0 コメント:
コメントを投稿