SimeonTs

SUPyF2 D.Types and Vars Exercise - 04. Sum of Chars

Sep 27th, 2019
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1. """
  2. Data Types and Variables - Exercise
  3. Check your code: https://judge.softuni.bg/Contests/Practice/Index/1722#3
  4.  
  5. SUPyF2 D.Types and Vars Exercise - 04. Sum of Chars
  6. Problem:
  7. Write a program, which sums the ASCII codes of n characters and prints the sum on the console.
  8. Input
  9. • On the first line, you will receive n – the number of lines, which will follow
  10. • On the next n lines – you will receive letters from the Latin alphabet
  11. Output
  12. Print the total sum in the following format:
  13. The sum equals: {total_sum}
  14. Constraints
  15. • n will be in the interval [1…20].
  16. • The characters will always be either upper or lower-case letters from the English alphabet
  17. • You will always receive one letter per line
  18. Examples:
  19. Input:
  20. 5
  21. A
  22. b
  23. C
  24. d
  25. E
  26. Output:
  27. The sum equals: 399
  28. Input:
  29. 12
  30. S
  31. o
  32. f
  33. t
  34. U
  35. n
  36. i
  37. R
  38. u
  39. l
  40. z
  41. z
  42. Output:
  43. The sum equals: 1263
  44. """
  45. total = 0
  46. for symbol in range(int(input())):
  47.     total += ord(input())
  48.  
  49. print(f"The sum equals: {total}")
Add Comment
Please, Sign In to add comment