Completed 10-10 Common Words
This commit is contained in:
parent
c7cb0c5bde
commit
15d3729776
28
Chapter_10/10-10_common_words.py
Normal file
28
Chapter_10/10-10_common_words.py
Normal file
@ -0,0 +1,28 @@
|
||||
# Exercise 10-10 Common Words
|
||||
# Learning Objective: Take a free ebook and gather data on how many times a word is found within it.
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
book1 = Path("./Chapter_10/bible.txt")
|
||||
bible = book1.read_text()
|
||||
print("\n\nKing James Version Bible Stats:\n")
|
||||
print(f"THERE: {bible.lower().count('there')}")
|
||||
print(f"THEM: {bible.lower().count('them')}")
|
||||
print(f"THE: {bible.lower().count('the')}")
|
||||
print(f"THE : {bible.lower().count('the ')}")
|
||||
|
||||
book2 = Path("./Chapter_10/scientific_american_vol_37.txt")
|
||||
sciam = book2.read_text()
|
||||
print("\n\nScientific American, Vol XXXVII STATS:\n")
|
||||
print(f"THERE: {sciam.lower().count('there')}")
|
||||
print(f"THEM: {sciam.lower().count('them')}")
|
||||
print(f"THE: {sciam.lower().count('the')}")
|
||||
print(f"THE : {sciam.lower().count('the ')}")
|
||||
|
||||
book3 = Path("./Chapter_10/the_manufacture_of_paper.txt")
|
||||
paper = book3.read_text()
|
||||
print("\n\n THE MANUFACTURE OF PAPER STATS:\n")
|
||||
print(f"THERE: {paper.lower().count('there')}")
|
||||
print(f"THEM: {paper.lower().count('them')}")
|
||||
print(f"THE: {paper.lower().count('the')}")
|
||||
print(f"THE : {paper.lower().count('the ')}")
|
||||
99968
Chapter_10/bible.txt
Normal file
99968
Chapter_10/bible.txt
Normal file
File diff suppressed because it is too large
Load Diff
6279
Chapter_10/scientific_american_vol_37.txt
Normal file
6279
Chapter_10/scientific_american_vol_37.txt
Normal file
File diff suppressed because it is too large
Load Diff
10530
Chapter_10/the_manufacture_of_paper.txt
Normal file
10530
Chapter_10/the_manufacture_of_paper.txt
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user