Book.py example

This example shows testing your completed lab. Here we will walk through a whole stream of actions from buying books to seeing books to reading books. This example also shows how you should handle invalid input when trying to read books. Pay attention to how the bookmarks get updated for each book as we read and quit them.

python3 ereader.py

Since this is the first time you used it,
let's customize your Swindle...

Please enter you name: Vasanta

Welcome to Vasanta's Swindle v1.0!

--------------------------------------------------

1) Buy/See available books
2) See owned books
3) Read a book
4) Exit

   ---> 3
You don't have any books that you own!
How about buying some books first?
--------------------------------------------------

1) Buy/See available books
2) See owned books
3) Read a book
4) Exit

   ---> 2

You don't own any books!
--------------------------------------------------

1) Buy/See available books
2) See owned books
3) Read a book
4) Exit

   ---> 1
1         GettysburgAddress      Abraham Lincoln (1863)
2       Alice in Wonderland        Lewis Carroll (1865)
3       Pride and Prejudice          Jane Austin (1813)
4                 Peter Pan         J. M. Barrie (1922)
5                   Ulysses          James Joyce (1922)
6    Mary Had a Little Lamb   Sarah Josepha Hale (1830)

Which book would you like to buy? (0 to skip): 3

You've successfully purchased the book: Pride and Prejudice

--------------------------------------------------

1) Buy/See available books
2) See owned books
3) Read a book
4) Exit

   ---> 1
1         GettysburgAddress      Abraham Lincoln (1863)
2       Alice in Wonderland        Lewis Carroll (1865)
3                 Peter Pan         J. M. Barrie (1922)
4                   Ulysses          James Joyce (1922)
5    Mary Had a Little Lamb   Sarah Josepha Hale (1830)

Which book would you like to buy? (0 to skip): 5

You've successfully purchased the book: Mary Had a Little Lamb

--------------------------------------------------

1) Buy/See available books
2) See owned books
3) Read a book
4) Exit

   ---> 2
1       Pride and Prejudice          Jane Austin (1813)
2    Mary Had a Little Lamb   Sarah Josepha Hale (1830)
--------------------------------------------------

1) Buy/See available books
2) See owned books
3) Read a book
4) Exit

   ---> 3

Bookes you own:

1       Pride and Prejudice          Jane Austin (1813)
2    Mary Had a Little Lamb   Sarah Josepha Hale (1830)

Which book would you like to read? (0 to skip): 3

Please enter a valid choice from the options below

1       Pride and Prejudice          Jane Austin (1813)
2    Mary Had a Little Lamb   Sarah Josepha Hale (1830)

Which book would you like to read? (0 to skip): -3

Please enter a valid choice from the options below

1       Pride and Prejudice          Jane Austin (1813)
2    Mary Had a Little Lamb   Sarah Josepha Hale (1830)

Which book would you like to read? (0 to skip): 0
--------------------------------------------------

1) Buy/See available books
2) See owned books
3) Read a book
4) Exit

   ---> 3

Bookes you own:

1       Pride and Prejudice          Jane Austin (1813)
2    Mary Had a Little Lamb   Sarah Josepha Hale (1830)

Which book would you like to read? (0 to skip): 1
====================================================================================
|                                                                                  |
|                                                                                  |
|                                                                                  |
|                                                                                  |
| Pride and Prejudice                                                              |
|                                                                                  |
| by Jane Austen                                                                   |
|                                                                                  |
|                                                                                  |
|                                                                                  |
|                                                                                  |
| Chapter 1                                                                        |
|                                                                                  |
|                                                                                  |
| It is a truth universally acknowledged, that a single man in                     |
| possession of a good fortune, must be in want of a wife.                         |
|                                                                                  |
| However little known the feelings or views of such a man may                     |
| be on his first entering a neighbourhood, this truth is so well                  |
| fixed in the minds of the surrounding families, that he is considered            |
====================================================================================

Showing page 0 out of 711

n (next); p (previous); q (quit): n

====================================================================================
| the rightful property of some one or other of their daughters.                   |
|                                                                                  |
| "My dear Mr. Bennet," said his lady to him one day, "have you                    |
| heard that Netherfield Park is let at last?"                                     |
|                                                                                  |
| Mr. Bennet replied that he had not.                                              |
|                                                                                  |
| "But it is," returned she; "for Mrs. Long has just been here, and                |
| she told me all about it."                                                       |
|                                                                                  |
| Mr. Bennet made no answer.                                                       |
|                                                                                  |
| "Do you not want to know who has taken it?" cried his wife                       |
| impatiently.                                                                     |
|                                                                                  |
| "You want to tell me, and I have no objection to hearing it."                  |
|                                                                                  |
| This was invitation enough.                                                      |
|                                                                                  |
| "Why, my dear, you must know, Mrs. Long says that Netherfield                    |
====================================================================================

Showing page 1 out of 711

n (next); p (previous); q (quit): n

====================================================================================
| is taken by a young man of large fortune from the north of                       |
| England; that he came down on Monday in a chaise and four to                     |
| see the place, and was so much delighted with it, that he agreed                 |
| with Mr. Morris immediately; that he is to take possession                       |
| before Michaelmas, and some of his servants are to be in the                     |
| house by the end of next week."                                                  |
|                                                                                  |
| "What is his name?"                                                              |
|                                                                                  |
| "Bingley."                                                                       |
|                                                                                  |
| "Is he married or single?"                                                       |
|                                                                                  |
| "Oh!  Single, my dear, to be sure!  A single man of large                        |
| fortune; four or five thousand a year.  What a fine thing for our                |
| girls!"                                                                          |
|                                                                                  |
| "How so?  How can it affect them?"                                               |
|                                                                                  |
| "My dear Mr. Bennet," replied his wife, "how can you be so                       |
====================================================================================

Showing page 2 out of 711

n (next); p (previous); q (quit): n

====================================================================================
| tiresome!  You must know that I am thinking of his marrying                      |
| one of them."                                                                    |
|                                                                                  |
| "Is that his design in settling here?"                                           |
|                                                                                  |
| "Design!  Nonsense, how can you talk so!  But it is very likely                  |
| that he may fall in love with one of them, and therefore you                   |
| must visit him as soon as he comes."                                             |
|                                                                                  |
| "I see no occasion for that.  You and the girls may go, or you                   |
| may send them by themselves, which perhaps will be still                         |
| better, for as you are as handsome as any of them, Mr. Bingley                   |
| may like you the best of the party."                                             |
|                                                                                  |
| "My dear, you flatter me.  I certainly have had my share of                    |
| beauty, but I do not pretend to be anything extraordinary now.                   |
| When a woman has five grown-up daughters, she ought to give                      |
| over thinking of her own beauty."                                                |
|                                                                                  |
| "In such cases, a woman has not often much beauty to think of."                  |
====================================================================================

Showing page 3 out of 711

n (next); p (previous); q (quit): p
====================================================================================
| is taken by a young man of large fortune from the north of                       |
| England; that he came down on Monday in a chaise and four to                     |
| see the place, and was so much delighted with it, that he agreed                 |
| with Mr. Morris immediately; that he is to take possession                       |
| before Michaelmas, and some of his servants are to be in the                     |
| house by the end of next week."                                                  |
|                                                                                  |
| "What is his name?"                                                              |
|                                                                                  |
| "Bingley."                                                                       |
|                                                                                  |
| "Is he married or single?"                                                       |
|                                                                                  |
| "Oh!  Single, my dear, to be sure!  A single man of large                        |
| fortune; four or five thousand a year.  What a fine thing for our                |
| girls!"                                                                          |
|                                                                                  |
| "How so?  How can it affect them?"                                               |
|                                                                                  |
| "My dear Mr. Bennet," replied his wife, "how can you be so                       |
====================================================================================

Showing page 2 out of 711

n (next); p (previous); q (quit): q

Setting bookmark in Pride and Prejudice to page 2

--------------------------------------------------

1) Buy/See available books
2) See owned books
3) Read a book
4) Exit

   ---> 3

Bookes you own:

1       Pride and Prejudice          Jane Austin (1813)
2    Mary Had a Little Lamb   Sarah Josepha Hale (1830)

Which book would you like to read? (0 to skip): 1
====================================================================================
| is taken by a young man of large fortune from the north of                       |
| England; that he came down on Monday in a chaise and four to                     |
| see the place, and was so much delighted with it, that he agreed                 |
| with Mr. Morris immediately; that he is to take possession                       |
| before Michaelmas, and some of his servants are to be in the                     |
| house by the end of next week."                                                  |
|                                                                                  |
| "What is his name?"                                                              |
|                                                                                  |
| "Bingley."                                                                       |
|                                                                                  |
| "Is he married or single?"                                                       |
|                                                                                  |
| "Oh!  Single, my dear, to be sure!  A single man of large                        |
| fortune; four or five thousand a year.  What a fine thing for our                |
| girls!"                                                                          |
|                                                                                  |
| "How so?  How can it affect them?"                                               |
|                                                                                  |
| "My dear Mr. Bennet," replied his wife, "how can you be so                       |
====================================================================================

Showing page 2 out of 711

n (next); p (previous); q (quit): n

====================================================================================
| tiresome!  You must know that I am thinking of his marrying                      |
| one of them."                                                                    |
|                                                                                  |
| "Is that his design in settling here?"                                           |
|                                                                                  |
| "Design!  Nonsense, how can you talk so!  But it is very likely                  |
| that he may fall in love with one of them, and therefore you                   |
| must visit him as soon as he comes."                                             |
|                                                                                  |
| "I see no occasion for that.  You and the girls may go, or you                   |
| may send them by themselves, which perhaps will be still                         |
| better, for as you are as handsome as any of them, Mr. Bingley                   |
| may like you the best of the party."                                             |
|                                                                                  |
| "My dear, you flatter me.  I certainly have had my share of                    |
| beauty, but I do not pretend to be anything extraordinary now.                   |
| When a woman has five grown-up daughters, she ought to give                      |
| over thinking of her own beauty."                                                |
|                                                                                  |
| "In such cases, a woman has not often much beauty to think of."                  |
====================================================================================

Showing page 3 out of 711

n (next); p (previous); q (quit): n

====================================================================================
|                                                                                  |
| "But, my dear, you must indeed go and see Mr. Bingley when                       |
| he comes into the neighbourhood."                                                |
|                                                                                  |
| "It is more than I engage for, I assure you."                                    |
|                                                                                  |
| "But consider your daughters.  Only think what an establishment                  |
| it would be for one of them.  Sir William and Lady Lucas are                     |
| determined to go, merely on that account, for in general, you                    |
| know, they visit no newcomers.  Indeed you must go, for it will                  |
| be impossible for us to visit him if you do not."                              |
|                                                                                  |
| "You are over-scrupulous, surely.  I dare say Mr. Bingley will                   |
| be very glad to see you; and I will send a few lines by you to                   |
| assure him of my hearty consent to his marrying whichever he                     |
| chooses of the girls; though I must throw in a good word for                     |
| my little Lizzy."                                                                |
|                                                                                  |
| "I desire you will do no such thing.  Lizzy is not a bit better                  |
| than the others; and I am sure she is not half so handsome as                    |
====================================================================================

Showing page 4 out of 711

n (next); p (previous); q (quit): n

====================================================================================
| Jane, nor half so good-humoured as Lydia.  But you are always                    |
| giving her the preference."                                                    |
|                                                                                  |
| "They have none of them much to recommend them," replied he;                     |
| "they are all silly and ignorant like other girls; but Lizzy                     |
| has something more of quickness than her sisters."                               |
|                                                                                  |
| "Mr. Bennet, how can you abuse your own children in such a                     |
| way?  You take delight in vexing me.  You have no compassion                     |
| for my poor nerves."                                                             |
|                                                                                  |
| "You mistake me, my dear.  I have a high respect for your                        |
| nerves.  They are my old friends.  I have heard you mention                      |
| them with consideration these last twenty years at least."                       |
|                                                                                  |
| "Ah, you do not know what I suffer."                                             |
|                                                                                  |
| "But I hope you will get over it, and live to see many young                     |
| men of four thousand a year come into the neighbourhood."                        |
|                                                                                  |
====================================================================================

Showing page 5 out of 711

n (next); p (previous); q (quit): q

Setting bookmark in Pride and Prejudice to page 5

--------------------------------------------------

1) Buy/See available books
2) See owned books
3) Read a book
4) Exit

   ---> 3

Bookes you own:

1       Pride and Prejudice          Jane Austin (1813)
2    Mary Had a Little Lamb   Sarah Josepha Hale (1830)

Which book would you like to read? (0 to skip): 2
====================================================================================
| Mary had a little lamb,                                                          |
| whose fleece was white as snow.                                                  |
|                                                                                  |
| And everywhere that Mary went,                                                   |
| the lamb was sure to go.                                                         |
|                                                                                  |
| It followed her to school one day                                                |
| which was against the rules.                                                     |
|                                                                                  |
| It made the children laugh and play,                                             |
| to see a lamb at school.                                                         |
|                                                                                  |
| And so the teacher turned it out,                                                |
| but still it lingered near,                                                      |
|                                                                                  |
| And waited patiently about,                                                      |
| till Mary did appear.                                                            |
|                                                                                  |
| "Why does the lamb love Mary so?"                                                |
| the eager children cry.                                                          |
====================================================================================

Showing page 0 out of 1

n (next); p (previous); q (quit): n

====================================================================================
|                                                                                  |
| "Why, Mary loves the lamb, you know."                                            |
|  the teacher did reply.                                                          |
|                                                                                  |
====================================================================================

Showing page 1 out of 1

n (next); p (previous); q (quit): n


You finished the book!


Setting bookmark in Mary Had a Little Lamb to page 0

--------------------------------------------------

1) Buy/See available books
2) See owned books
3) Read a book
4) Exit

   ---> 3

Bookes you own:

1       Pride and Prejudice          Jane Austin (1813)
2    Mary Had a Little Lamb   Sarah Josepha Hale (1830)

Which book would you like to read? (0 to skip): 1
====================================================================================
| Jane, nor half so good-humoured as Lydia.  But you are always                    |
| giving her the preference."                                                    |
|                                                                                  |
| "They have none of them much to recommend them," replied he;                     |
| "they are all silly and ignorant like other girls; but Lizzy                     |
| has something more of quickness than her sisters."                               |
|                                                                                  |
| "Mr. Bennet, how can you abuse your own children in such a                     |
| way?  You take delight in vexing me.  You have no compassion                     |
| for my poor nerves."                                                             |
|                                                                                  |
| "You mistake me, my dear.  I have a high respect for your                        |
| nerves.  They are my old friends.  I have heard you mention                      |
| them with consideration these last twenty years at least."                       |
|                                                                                  |
| "Ah, you do not know what I suffer."                                             |
|                                                                                  |
| "But I hope you will get over it, and live to see many young                     |
| men of four thousand a year come into the neighbourhood."                        |
|                                                                                  |
====================================================================================

Showing page 5 out of 711

n (next); p (previous); q (quit): q

Setting bookmark in Pride and Prejudice to page 5

--------------------------------------------------

1) Buy/See available books
2) See owned books
3) Read a book
4) Exit

   ---> 3

Bookes you own:

1       Pride and Prejudice          Jane Austin (1813)
2    Mary Had a Little Lamb   Sarah Josepha Hale (1830)

Which book would you like to read? (0 to skip): 2
====================================================================================
| Mary had a little lamb,                                                          |
| whose fleece was white as snow.                                                  |
|                                                                                  |
| And everywhere that Mary went,                                                   |
| the lamb was sure to go.                                                         |
|                                                                                  |
| It followed her to school one day                                                |
| which was against the rules.                                                     |
|                                                                                  |
| It made the children laugh and play,                                             |
| to see a lamb at school.                                                         |
|                                                                                  |
| And so the teacher turned it out,                                                |
| but still it lingered near,                                                      |
|                                                                                  |
| And waited patiently about,                                                      |
| till Mary did appear.                                                            |
|                                                                                  |
| "Why does the lamb love Mary so?"                                                |
| the eager children cry.                                                          |
====================================================================================

Showing page 0 out of 1

n (next); p (previous); q (quit): n

====================================================================================
|                                                                                  |
| "Why, Mary loves the lamb, you know."                                            |
|  the teacher did reply.                                                          |
|                                                                                  |
====================================================================================

Showing page 1 out of 1

n (next); p (previous); q (quit): q

Setting bookmark in Mary Had a Little Lamb to page 1

--------------------------------------------------

1) Buy/See available books
2) See owned books
3) Read a book
4) Exit

   ---> 3

Bookes you own:

1       Pride and Prejudice          Jane Austin (1813)
2    Mary Had a Little Lamb   Sarah Josepha Hale (1830)

Which book would you like to read? (0 to skip): 2
====================================================================================
|                                                                                  |
| "Why, Mary loves the lamb, you know."                                            |
|  the teacher did reply.                                                          |
|                                                                                  |
====================================================================================

Showing page 1 out of 1

n (next); p (previous); q (quit): q

Setting bookmark in Mary Had a Little Lamb to page 1

--------------------------------------------------

1) Buy/See available books
2) See owned books
3) Read a book
4) Exit

   ---> 4