-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathLetterSum.py
More file actions
38 lines (26 loc) · 683 Bytes
/
Copy pathLetterSum.py
File metadata and controls
38 lines (26 loc) · 683 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# GHC Codepath SE101
# BASIC
# Sandbox - 4
#!/bin/python3
import math
import os
import random
import re
import sys
# The function is expected to return an INTEGER.
# The function accepts STRING vals as parameter.
# The function will summate the ASCII values of
# the characters in the string it accepts as a
# parameter.
def summate(vals):
sum_string = 0
# assumption: all elements in a string are letters
for i in vals:
sum_string += ord(i)
return sum_string
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
vals = input()
result = summate(vals)
fptr.write(str(result) + '\n')
fptr.close()