Advertisement
joseleeph

Untitled

Nov 28th, 2020
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 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 range(len(s)):
  10. for i in s:
  11. if i.isalpha():
  12. lc += 1
  13. #if i.isalpha():
  14. #lc += 1
  15. #if string.isalpha(i):
  16. #lc += 1
  17. #if i == ' ':
  18. #wc += 1
  19. if i.isalpha() and not i.isspace():
  20. wc += 1
  21. if i == '.' or i == '!' or i == '?':
  22. sc += 1
  23. else:
  24. lc += 1
  25. wc += 1
  26. # wc += 1 ???
  27.  
  28. L = lc/wc * 100
  29. S = sc/wc * 100
  30. index = 0.0588*L - 0.296*S - 15.8
  31. ir = index.round()
  32.  
  33. #if (round(index) < 1):
  34. #if index.round() < 1:
  35. if ir < 1:
  36. print("Before Grade 1")
  37. #elif index.round() >= 16:
  38. elif ir >= 16:
  39. print("Grade 16+")
  40. #elif (round(index) >= 16):
  41. print("Grade 16+")
  42. else:
  43. print("Grade")
  44. #print(int(round(index)))
  45. print(ir)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement