mirror of https://github.com/me50/kukemuna.git
automated commit by check50 [check50=True]
This commit is contained in:
commit
296e43d627
|
|
@ -0,0 +1,36 @@
|
|||
def main():
|
||||
text = input("Text: ")
|
||||
|
||||
letters = get_letters(text)
|
||||
words = len(text.split())
|
||||
sentences = get_sentences(text)
|
||||
|
||||
index = round(0.0588 * (100 * letters / words) - 0.296 * (100 * sentences / words) - 15.8)
|
||||
|
||||
if (index < 1):
|
||||
print("Before Grade 1")
|
||||
|
||||
elif (index >= 16):
|
||||
print("Grade 16+")
|
||||
|
||||
else:
|
||||
print(f"Grade {index}")
|
||||
|
||||
|
||||
def get_letters(text):
|
||||
count = 0
|
||||
for i in range(len(text)):
|
||||
if (text[i].isalpha()):
|
||||
count += 1
|
||||
return count
|
||||
|
||||
|
||||
def get_sentences(text):
|
||||
count = 0
|
||||
for i in range(len(text)):
|
||||
if (text[i] == '.' or text[i] == '!' or text[i] == '?'):
|
||||
count += 1
|
||||
return count
|
||||
|
||||
|
||||
main()
|
||||
Loading…
Reference in New Issue