write a program in Python 3.xx Numerologists claim to be able to determine a per
ID: 3676800 • Letter: W
Question
write a program in Python 3.xx
Numerologists claim to be able to determine a person's character traits based on the "numeric value" of a name. The value of a name is determined by summing up the vaules of the letters of the name where 'a' is 1, 'b' is 2, 'c' 3 etc., up to 'z' being 26. For example, the name "Zelle" would have the value 26+5+12+12+5=60. Write a program that calculates the numeric value of a single name provided as input.
make sure output is something like this:
Enter name :zelle
z 26
e 5
l 12
l 12
e 5
The numeric value for zelle is: 60
not like this
Enter name :zelle
z 26
e 31
l 43
l 55
e 60
The numeric value for zelle is: 60
Explanation / Answer
from string import join,upper,lower,capitalize,split
def main():
print "Find the numeric value of a name."
print
names=[]
names = split(upper(raw_input("Please enter name: ")))
total = 0
for name in names:
for ch in name:
# A is 65
total = total+ ord(ch)-64
print "Numeric value of %s is %d" % (capitalize(lower(name)),total)
main()
output
Find the numeric value of a name.
Please enter name: Zelle
Numeric value of Zelle is 60
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.