2017年12月23日土曜日

開発環境

Teach Your Kids to Code: A Parent-Friendly Guide to Python Programming (Bryson Payne(著)、No Starch Press)のChapter 1.(Python Basics: Get to Know Your Environment)、PROGRAMMING CHALLENGES、#1:MAD LIBS(No. 417)を取り組んでみる。

#1:MAD LIBS(No. 417)

コード(Emacs)

Python 3

#!/usr/bin/env python3

adjective = input('Please enter an adjective: ')
noun = input('Please enter a noun: ')
verb = input('Please enter a ending in -ed: ')
print('Your MadLib:')
print(f'The {adjective} {noun} {verb} over the lazy brown dog.')

入出力結果(Terminal, Jupyter(IPython))

$ ./MadLib.py 
Please enter an adjective: smart
Please enter a noun: teacher
Please enter a ending in -ed: sneezed
Your MadLib:
The smart teacher sneezed over the lazy brown dog.
$

0 コメント:

コメントを投稿