https://www.youtube.com/playlist?list=PLhOuww6rJJNOWShq53st6NjXacHHaJurn
Write a Shakesperean insult generator:
$ ./abuse.pyYou foul, filthsome swine!You foolish, sodden-witted ratcatcher!You ruinous, bankrupt jolthead!
The insults are generated by randomly combining these adjectives:
bankrupt base caterwauling corrupt cullionly detestable dishonest falsefilthsome filthy foolish foul gross heedless indistinguishable infectedinsatiate irksome lascivious lecherous loathsome lubbery old peevishrascaly rotten ruinous scurilous scurvy slanderous sodden-wittedthin-faced toad-spotted unmannered vile wall-eyed
With these nouns:
Judas Satan ape ass barbermonger beggar block boy braggart buttcarbuncle coward coxcomb cur dandy degenerate fiend fishmonger foolgull harpy jack jolthead knave liar lunatic maw milksop minionratcatcher recreant rogue scold slave swine traitor varlet villain worm
The program can vary the -n
or --number
of insults:
$ ./abuse.py -n 2You heedless, gross barbermonger!You bankrupt, vile scold!
Or the number of --adjectives
(also -a
):
$ ./abuse.py -a 4You sodden-witted, ruinous, lecherous, lubbery villain!You insatiate, caterwauling, corrupt, toad-spotted traitor!You vile, unmannered, ruinous, filthy liar!
The program should accept a -s
or --seed
to set the random seed for reproducible results:
$ ./abuse.py -s 1You filthsome, cullionly fiend!You false, thin-faced minion!You sodden-witted, rascaly cur!
Your program should respond to -h
and --help
with a usage:
$ ./abuse.py -husage: abuse.py [-h] [-a int] [-n int] [-s int]Heap abuseoptional arguments: -h, --help show this help message and exit -a int, --adjectives int Number of adjectives (default: 2) -n int, --number int Number of insults (default: 3) -s int, --seed int Random seed (default: None)
Run the test suite to ensure your program is correct:
$ make testpytest -xv test.py============================= test session starts ==============================...collected 11 itemstest.py::test_exists PASSED [ 9%]test.py::test_usage PASSED [ 18%]test.py::test_bad_adjective_str PASSED [ 27%]test.py::test_bad_adjective_num PASSED [ 36%]test.py::test_bad_number_str PASSED [ 45%]test.py::test_bad_number_int PASSED [ 54%]test.py::test_bad_seed PASSED [ 63%]test.py::test_01 PASSED [ 72%]test.py::test_02 PASSED [ 81%]test.py::test_03 PASSED [ 90%]test.py::test_04 PASSED [100%]============================== 11 passed in 0.74s ==============================
Reviews
There are no reviews yet.