Head First Programming
A learner's guide to programming
using the Python language
( O'Reilly Media; )
David Griffiths (著) Paul Barry (著)
開発環境
- OS X Mavericks - Apple(OS)
- Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
- Python (プログラミング言語)
Head First Programming A learner's guide to programming using the Python language (David Griffiths(著)、Paul Barry(著)、 O'Reilly Media; )のChapter1(Starting to Code: Finding your way)、Long Exercise(p.30)を解いてみる。
Long Exercise(p.30)
コード(BBEdit)
sample30.py
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
print('Welcome!')
guess = 0
while guess != 5:
g = input('Guee the number: ')
guess = int(g)
if guess == 5:
print('You win!')
else:
if guess > 5:
print('Too high')
else:
print('Too low')
print('Game over!')
入出力結果(Terminal)
$ ./sample30.py Welcome! Guee the number: 1 Too low Guee the number: 10 Too high Guee the number: 5 You win! Game over! $
0 コメント:
コメントを投稿