joseleeph

Untitled

Nov 28th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. from cs50 import get_string
  2.  
  3.  
  4. s = get_string("Input: ")
  5. lc = 0
  6. wc = 0
  7. sc = 0
  8.  
  9. for i in s:
  10. if i.isalpha():
  11. lc += 1
  12. #if i.isalpha():
  13. #lc += 1
  14. #if string.isalpha(i):
  15. #lc += 1
  16. elif i == ' ':
  17. wc += 1
  18. #elif i.isalpha(): #and not i.isspace():
  19. #wc += 1
  20. elif i == '.' or i == '!' or i == '?':
  21. sc += 1
  22. else:
  23. lc += 1
  24. wc += 1
  25.  
  26.  
  27. L = lc/wc * 100
  28. S = sc/wc * 100
  29. index = 0.0588*L - 0.296*S - 15.8
  30.  
  31. ir = round(index)
  32.  
  33. if ir < 1:
  34. print("Before Grade 1")
  35. elif ir >= 16:
  36. print("Grade 16+")
  37. else:
  38. print("Grade")
  39. print(ir)
  40.  
Advertisement
Add Comment
Please, Sign In to add comment