MeShootIn

8-1

Dec 9th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.76 KB | None | 0 0
  1. # ---------------------------------
  2. # СТАТИСТИКА СИМВОЛОВ В ТЕКСТЕ
  3. # ВЫПОЛНИЛ: ДМИТРИЙ МИШУТИН, КЭ - 101
  4. # ---------------------------------
  5.  
  6.  
  7. inp = open("input.txt", "r")
  8. out = open("output.txt", "w")
  9.  
  10. letters = 0
  11. digits = 0
  12. chars = 0
  13.  
  14. arr = list(inp.read())
  15.  
  16. for i in range(len(arr)):
  17.     if ord("A") <= ord(arr[i]) <= ord("Z") or ord("a") <= ord(arr[i]) <= ord("z"):
  18.         letters += 1
  19.     if ord("0") <= ord(arr[i]) <= ord("9"):
  20.         digits += 1
  21.     if arr[i] in [".", ",", "?", "!"]:
  22.         chars += 1
  23.  
  24. out.write("Count of letters: " + str(letters) + "\n")
  25. out.write("Count of digits: " + str(digits) + "\n")
  26. out.write("Count of punctuation marks: " + str(chars) + "\n")
  27.  
  28. inp.close()
  29. out.close()
Add Comment
Please, Sign In to add comment