2017年12月24日日曜日

開発環境

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、#2:MORE MAD LIBS!(No. 417)を取り組んでみる。

#2:MORE 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: ')
animal = input('Please enter a animal: ')
print('Your MadLib:')
print(f'The {adjective} {noun} {verb} over the lazy brown {animal}.')

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

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

0 コメント:

コメントを投稿