Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implem ent a function which will take a file, grab the unique words in the file, print the number of unique words and return a

Implemimage text in transcribedent a function which will take a file, grab the unique words in the file, print the number of unique words and return a sorted list. You must use set for this problem.

shortfile.txt

abc aaa bac aaa bbb ccc ddd ed de ffa aff

catinhat.txt

the sun did not shine. it was too wet to play. so we sat in the house all that cold, cold, wet day.

i sat there with sally. we sat there, we two. and i said, 'how i wish we had something to do!'

too wet to go out and too cold to play ball. so we sat in the house. we did nothing at all.

so all we could do was to sit! sit! sit! sit! and we did not like it. not one little bit.

and then something went BUMP! how that bump made us jump! we looked! then we saw him step in on the mat! we looked! and we saw him! the cat in the hat! and he said to us, 'why do you sit there like that?' 'i know it is wet and the sun is not sunny. but we can have lots of good fun that is funny!'

'i know some good games we could play,' said the cat. 'i know some new tricks,' said the cat in hte hat. 'a lot of good tricks. i will show them to you. your mother will not mind at all if i do.'

then sally and i did not know what to say. our mother was out of the house for the day.

but our fish said, 'no! no! make that cat go away! tell that cat in the hat you do NOT want to play. he should not be here. he should not be about. he should not be here when your mother is out!'

'now! now! have no fear. have no fear!' said the cat. 'my tricks are not bad,' said the cat in the hat. 'why, we can have lots of good fun, if you wish, with a game that i call up-up-up with a fish!'

'put me down!' said the fish. 'this is no fun at all! put me down!' said the fish. 'i do NOT wish to fall!'

'have no fear!' said the cat. 'i will not let you fall. i will hold you up high as i stand on a ball. with a book one one hand! and a cup on my hat! but that is not ALL i can do! said the cat...

'look at me! look at me now!' said the cat. 'with a cup and a cake on the top of my hat! i can hold up TWO books! i can hold up the fish! and a little toy ship! and some milk on a dish! and look! i can hop up and down on the ball! but that is not all! oh, no. that is not all...

'look at me! look at me! look at me NOW! it is fun to have fun but you have to know how. i can hold up the cup and the milk and the cake! i can hold up these books! and the fish on a rake! i can hold the toy ship and a little toy man! and look! with my tail i can hold a red fan! i can fan with the fan as i hop on the ball! but that is not all. oh, no. that is not all...'

that is what the cat said... then he fell on his head! he came down with a bump from up there on the ball. and sally and i, we saw ALL the things fall!

and our fish came down, too. he fell into a pot! he said, 'do i like this? oh, no! i do not. this is not a good game,' said our fish as he lit. 'no, i do not like it, not one little bit!'

'now look what you did!' said the fish to the cat. 'now look at this house! look at this! look at that! you sank our toy ship, sank it deep in the cake. you shook up our house and you bent our new rake. you SHOULD NOT be here when our mother is not. you get out of this house!' said the fish in the pot.

'but i like to be here. oh, i like it a lot!' said the cat in the hat to the fish in the pot. 'i will NOT go away. i do NOT wish to go! and so,' said the cat in the hat, 'so so so... i will show you another good game that i know!'

and then he ran out. and, then, fast as a fox, the cat in the hat came back in with a box. a big red wood box. it was shut with a hook. 'now look at this trick,' said the cat. 'take a look!'

then he got up on top with a tip of his hat. 'i call this game fun-in-a-box,' said the cat. 'in this box are two things i will show to you now. you will like these two things,' said the cat with a bow.

'i will pick up the hook. you will see something new. two things. and i call them Thing One and Thing Two. these Things will not bite you. they want to have fun.' then, out of the box came Thing Two and Thing One! and they ran to us fast. they said, 'how do you do? would you like to shake hands with Thing One and Thing Two?'

and sally and i did not know what to do. so we had to shake hands with Thing One and Thing Two. we shook their two hands. but our fish said, 'no! no! those Things should not be in this house! make them go! they should not be here when your mother is not! put them out! put them out!' said the fish in the pot.

'have no fear, little fish,' said the cat in the hat. 'these Things are good Things.' and he gave them a pat. 'they are tame. oh, so tame! they have come here to play. they will give you some fun on this wet, wet, wet day.'

now, here is a game that they like,' said the cat. 'they like to fly kites,' said the cat in the hat.

'no! not in the house!' said the fish in the pot. 'they should not fly kites in a house! they should not. oh, the things they will bump! oh, the things they will hit! oh, i do not like it! not one little bit!'

then sally and i saw them run down the hall. we saw those two Things bump their kites on the wall! bump! thump! thump! bump! down the wall in the hall.

thing two and thing one! they ran up! they ran down! on the string of one kite we saw mother's new gown! her gown with the dots that are pink, white and red. then we saw one kite bump on the head of her bed!

then those things ran about with big bumps, jumps and kicks and with hops and big thumps and all kinds of bad tricks. and i said, 'i do NOT like the way that they play! if mother could see this, oh, what would she say!'

then our fish said, 'look! look!' and our fish shook with fear. 'your mother is on her way home! do you hear? oh, what will she do to us? what will she say? oh, she will not like it to find us this way!'

'so DO something! fast!' said the fish. 'do you hear! i saw her. your mother! your mother is near! so, as fast as you can, think of something to do! you will have to get rid of thing one and thing two!'

so, as fast as i could, i went after my net. and i said, 'with my net i can get them i bet. i bet, with my net, i can get those things yet!'

then i let down my net. it came down with a PLOP! and i had them! at last! those two things had to stop. then i said to the cat, 'now you do as i say. you pack up those Things and you take them away!'

'oh dear!' said the cat. 'you did not like our game... oh dear. what a shame! what a shame! what a shame!'

then he shut up the things in the box with the hook. and the cat went away with a sad kind of look.

'that is good,' said the fish. 'he has gone away. yes. but your mother will come. she will find this big mess! and this mess is so big and so deep and so tall, we can not pick it up. there is no way at all!'

and THEN! who was back in the house? why, the cat! 'have no fear of this mess,' said the cat in the hat. 'i always pick up all my playthings and so... i will show you another good trick that i know!'

then we saw him pick up all the things that were down. he picked up the cake, and the rake, and the gown, and the milk, and the strings, and the books, and the dish, and the fan, and the cup, and the ship, and the fish. and he put them away. then he said, 'that is that.' and then he was gone with a tip of his hat.

then our mother came in and she said to us two, 'did you have any fun? tell me. what did you do?'

and sally and i did not know what to say. should we tell her the things that went on there that day?

should we tell her about it? now, what SHOULD we do? well... what would YOU do if your mother asked YOU?

unique Words ('C inha ['a', about after all always and another any are as asked at away back bad ball be bed bent bet big bit bite book books bow box. bump bumps but cake 'C all Came Can Cat cold come could Cup day dear deep did dish 'do', dots down fall fan fast fear fell find fish ly for fox from fun. un-in-a-box funny gam e', games gave get give go gone good got gown had hall. hand hands has hat have 'he', head hear her her e', high him his hit. hold home hook' hop hops house how hte 'i', if in into is it jump jumps kicks 'K ind kinds kite r kites know last let like "lit "little look looked lot lots made make man, mat 'me', 'mess', 'mi lk', mind mother my near net new 'no', not nothing 'now of oh On One Our Out pack pat pick picked pink play', playthings 'plop', pot put rake ran red rid 'run' '3', sad said sally sank 'sat', 'saw', say 'see', shake sha she shine ship shook should show shut sit SO 'so me something stand 'step', 'stop String r Strings r 'sun' r Sunny tail take tall 'tame tell that the their them then there these they', thing', things think thi. those thump thumps 'tip', to too top 'toy', trick tricks 'two', up up up-up', 'us', Wall Want 'was', Way 'We', Well, Went were Wet What when White Who why will 'wish', with Wood would yet you your Yes unique Words short file.txt') aaa abc aff bac 'bbb', 'ccc', 'ddd', de ed ffa, J

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data Fundamentals Concepts, Drivers & Techniques

Authors: Thomas Erl, Wajid Khattak, Paul Buhler

1st Edition

0134291204, 9780134291208

More Books

Students also viewed these Databases questions

Question

=+ What is the nature of the contracts or agreements with unions?

Answered: 1 week ago