Abuse Solved

25.00 $

Category:

Description

5/5 - (1 vote)

https://www.youtube.com/playlist?list=PLhOuww6rJJNOWShq53st6NjXacHHaJurn

Write a Shakesperean insult generator:

$ ./abuse.py
You 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 false
filthsome filthy foolish foul gross heedless indistinguishable infected
insatiate irksome lascivious lecherous loathsome lubbery old peevish
rascaly rotten ruinous scurilous scurvy slanderous sodden-witted
thin-faced toad-spotted unmannered vile wall-eyed

With these nouns:

Judas Satan ape ass barbermonger beggar block boy braggart butt
carbuncle coward coxcomb cur dandy degenerate fiend fishmonger fool
gull harpy jack jolthead knave liar lunatic maw milksop minion
ratcatcher recreant rogue scold slave swine traitor varlet villain worm

The program can vary the -n or --number of insults:

$ ./abuse.py -n 2
You heedless, gross barbermonger!
You bankrupt, vile scold!

Or the number of --adjectives (also -a):

$ ./abuse.py -a 4
You 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 1
You 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 -h
usage: abuse.py [-h] [-a int] [-n int] [-s int]

Heap abuse

optional 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 test
pytest -xv test.py
============================= test session starts ==============================
...
collected 11 items

test.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 ==============================
  • 09_abuse-qnjrd3.zip