Automate the Boring Stuff with Python:
Practical Programming for Total Beginners
(No Starch Press)
Al Sweigart (著)
開発環境
- OS X Yosemite - Apple (OS)
- Emacs (Text Editor)
- Python 3.4 (プログラミング言語)
Automate the Boring Stuff with Python: Practical Programming for Total Beginners (Al Sweigart (著)、No Starch Press)のPart Ⅰ.(Python Programming Basics)、Chapter 4.(Lists)、Practice Projects: Character Picture Grid(No. 2549)を解いてみる。
Practice Projects: Character Picture Grid(No. 2549)
コード(Emacs)
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
grid = [['.', '.', '.', '.', '.', '.'],
['.', 'O', 'O', '.', '.', '.'],
['O', 'O', 'O', 'O', '.', '.'],
['O', 'O', 'O', 'O', 'O', '.'],
['.', 'O', 'O', 'O', 'O', 'O'],
['O', 'O', 'O', 'O', 'O', '.'],
['O', 'O', 'O', 'O', '.', '.'],
['.', 'O', 'O', '.', '.', '.'],
['.', '.', '.', '.', '.', '.']]
for j in range(len(grid[0])):
for i in range(len(grid)):
print(grid[i][j], end='')
print()
入出力結果(Terminal, IPython)
$ ./sample.py ..OO.OO.. .OOOOOOO. .OOOOOOO. ..OOOOO.. ...OOO... ....O.... $
0 コメント:
コメントを投稿