開発環境
- OS X Yosemite - Apple (OS)
- Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
- Python 3.4 (プログラミング言語)
Python for Kids: A Playful Introduction to Programming (Jason R. Briggs (著) 、No Starch Press)のPart Ⅰ.(Learning to Program)、Chapter 3(Strings, Lists, Tuples, and Maps)、Programming Puzzles(No. 766)を解いてみる。
Programming Puzzles(No. 766)
コード(Emacs, BBEdit)
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
#1: Favorites
games = ['game1', 'game2']
foods = ['food1', 'food2']
favorites = games + foods
print(favorites)
#2: Counting Combatants
print(3 * 25 + 2 * 40)
#3: Greetings!
first_name = 'Brando'
last_name = 'Ickett'
print('Hi there, {first_name} {last_name}!'.format(
first_name=first_name, last_name=last_name))
入出力結果(Terminal, IPython)
$ ./sample.py ['game1', 'game2', 'food1', 'food2'] 155 Hi there, Brando Ickett! $
0 コメント:
コメントを投稿