Skip to content

Instantly share code, notes, and snippets.

@brootware
Last active May 11, 2022 07:07
Show Gist options
  • Save brootware/bf88c02acdc015fdb81974c5ea51faab to your computer and use it in GitHub Desktop.
Save brootware/bf88c02acdc015fdb81974c5ea51faab to your computer and use it in GitHub Desktop.
import math
data="""
Hello World, hi!
"""
# Words per minute
WPM = 75
# 3
def estimate_reading_time(text_chunk):
word_length = 5
total_words = 0
for current_text in text_chunk:
total_words += len(current_text)/word_length
total_words = math.ceil(total_words)
reading_minutes = math.ceil(total_words/WPM)
reading_hours = math.floor(reading_minutes/60)
two_deci_hours = round(reading_hours,2)
leftover_minutes = str(round(reading_hours,2)).split('.')
print(f"Estimated total words : {total_words}")
print(f"Estimated reading minutes : {reading_minutes}")
print(f"Estimated reading hours : {reading_hours}")
return None
print(estimate_reading_time(data))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment