開発環境
- macOS Mojave - Apple (OS)
- Emacs (Text Editor)
- Windows 10 Pro (OS)
- Visual Studio Code (Text Editor)
- Python 3.7 (プログラミング言語)
退屈なことはPythonにやらせよう ―ノンプログラマーにもできる自動化処理プログラミング (Al Sweigart(著)、相川 愛三(翻訳)、オライリージャパン)の第I部(Pythonプログラミングの基礎)、2章(フロー制御)、2.11(演習問題)2-1、2、3.を取り組んでみる。
コード(Emacs)
Python 3
#!/usr/bin/env python3
print('2-1.')
blns = [True, False]
for b in blns:
print(b)
print('2-2.')
print('and、or、not')
print('2-3.')
print('and')
for b1 in blns:
for b2 in blns:
print(f'{b1} and {b2}: {b1 and b2}')
print('or')
for b1 in blns:
for b2 in blns:
print(f'{b1} or {b2}: {b1 or b2}')
print('not')
for b in blns:
print(f'not {b}: {not b}')
入出力結果(Terminal, cmd(コマンドプロンプト), Jupyter(IPython))
$ ./sample1.py 2-1. True False 2-2. and、or、not 2-3. and True and True: True True and False: False False and True: False False and False: False or True or True: True True or False: True False or True: True False or False: False not not True: False not False: True $
0 コメント:
コメントを投稿