Advertisement
joseleeph

Untitled

Nov 28th, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 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.  
  32. if (round(index) < 1):
  33. print("Before Grade 1")
  34. elif (round(index) >= 16):
  35. print("Grade 16+")
  36. else:
  37. print("Grade")
  38. print(int(round(index)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement