Given a text file (FILE1) with lots of words (ex, an ebook),
and another file (FILE2) with a list of blacklist words
(slangs, porn, etc.), write a program to find the top 100
words(most frequent 100 words) from FILE1 which are not
present in FILE2.



Given a text file (FILE1) with lots of words (ex, an ebook), and another file (FILE2) with a list ..

Answer / siva kumar reddy dandu

Steps to solve this.
1. open FILE1 in read mode
2. read content by using read()
3 split content by using
so that you can get lines
4 split lines by split(' ') so that you can get words
5 repeat above 4 lines with file FILE2
6 iterate words list and create dictionary word and frequency as key values.
skip the value if it is found in file2 key words.
7 sort dict by using x= list(sorted(wordsarr.items(),wordsarr.get, reverse=true)
so that we can get sorted dict in desc order.
8 return top 100 words by using print(x[:101])

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More Python Interview Questions

How do you get a list of all the keys in a dictionary in python?

0 Answers  


What is instance of a class?

0 Answers  


Is python is a case sensitive?

0 Answers  


What are advantages and disadvantages of python?

0 Answers  


Do you know the number of keywords in python?

0 Answers  






What does by python a scripting language?

0 Answers  


Should I learn html before python?

0 Answers  


How do you check if a string contains a substring in python?

0 Answers  


How to send an email in python language?

0 Answers  


Is python useful for finance?

0 Answers  


Where is freeze for windows?

0 Answers  


Is python interpreted, or compiled, or both?

0 Answers  


Categories