Python 3.xx Numerologists claim to be able to determine a person\'s character tr
ID: 3676668 • Letter: P
Question
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
# -------------- PSEUDO CODE ------------------- # Define the main function # Get the input from the user, their name # for each character in their name: # convert it to a number, and add it to the total # display the total # Call the main function # -------------- PROGRAM ----------------------- """ ch05ex05.py, Chapter 5, Exercise 5 From Zelle's Python Programming, Chapter 5 This program converts a string to a "numerology" number @author Richard White @version 2015-10-13 """ def main(): username = input("Please enter your name, and I'll convert it to a number: ") usernumber = 0 # initialize for character in username: # convert to lower case... # convert to ordinal form # subtract so that a = 1 # add to total if character != " ": usernumber = usernumber + ord(character.lower())-96 print(usernumber) if __name__ == "__main__": main()
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.