I Need Help Please Writing This Program

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Feb 2006
Posts: 43
Reputation: butterflyTee is an unknown quantity at this point 
Solved Threads: 0
butterflyTee butterflyTee is offline Offline
Light Poster

I Need Help Please Writing This Program

 
0
  #1
Feb 21st, 2006
I need help please to write this program. 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. I am using my name Tamika.

Then, I have to expand my solution to the previous problem to allow the calculation of a complete name such as "Tamika Phai Mills." The total value is just the sum of the numeric values of all the names.
Last edited by butterflyTee; Feb 21st, 2006 at 8:48 pm. Reason: THIS A PYTHON PROGRAM
Quick reply to this message  
Join Date: Feb 2002
Posts: 12,047
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 129
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is offline Offline
The Queen of DaniWeb

Re: I Need Help Please Writing This Program

 
0
  #2
Feb 21st, 2006
We won't do your homework for you. We have our own work and schoolwork to do. What we WILL do is help you along. Let's break down this program and define an algorithm:

step 1 - prompt user for name
step 2 - save name into a string variable
step 3 - separate string into characters
step 4 - traverse the string and look at each character individually
step 5 - convert each character to its numerical "equivalent"
step 6 - use an accumulator variable and increment it each time we evaluate a character
step 7 - output the accumulator variable as the final sum

Does that make sense to you? See if you can come up with some code converting that algorithm into python. We'll then be more than happy to help you further, but you have to show us effort on your part.
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/DaniWeb
And if you're interested in Internet marketing there is twitter.com/DaniWebAds
Quick reply to this message  
Join Date: Oct 2004
Posts: 4,067
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 938
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: I Need Help Please Writing This Program

 
0
  #3
Feb 21st, 2006
Are you just counting letters, and they all have to be lower case?
May 'the Google' be with you!
Quick reply to this message  
Join Date: Feb 2006
Posts: 43
Reputation: butterflyTee is an unknown quantity at this point 
Solved Threads: 0
butterflyTee butterflyTee is offline Offline
Light Poster

Re: I Need Help Please Writing This Program

 
0
  #4
Feb 22nd, 2006
this what i got

  1. def main():
  2.  
  3. name = raw_input("Enter your name in lower case letter")
  4. letters = "a b c d e f g h i j k l m n o p q r s t u v w x y z"
  5. value = 0
  6. for i in name:
  7. print i
  8. value = string.find(letters, i ) + value
  9. print "The numeric value of your name is", value

Edit: Added [code] tags vegaseat
Last edited by vegaseat; Feb 23rd, 2006 at 11:10 am.
Quick reply to this message  
Join Date: Oct 2004
Posts: 4,067
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 938
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: I Need Help Please Writing This Program

 
0
  #5
Feb 23rd, 2006
Very nice thinking here, just needs a little touch up to work ...
[php]# using indexing

def main():

#name = raw_input("Enter your name in lower case letter")
# another option to get a lower case name
name = raw_input("Enter your name: ").lower()

# notice the space in front of 'a' this will give an index of a=1, b=2 and so on
# also gives a space an index of zero, so it won't count
letters = " abcdefghijklmnopqrstuvwxyz"

value = 0
for c in name:
print c, letters.find(c) # test
value = letters.find(c) + value
print "The numeric value of your name is", value

main()

[/php]
My original thought was to use the ASCII value of the lower case letters in the name. The function ord('a') would give 97 so you have to subtract 96 to get 'a'=1. Look at this code sample ...
[php]# using ASCII values

name = "Tamika Phai Mills".lower() # testing
sum = 0
for c in name:
# you want to count just letters, ord(c) give the ASCII value of the letter
if c.isalpha():
sum = sum + ord(c) - 96
print c, ord(c), ord(c) - 96, sum # test

print "result for '%s' = %d" % (name, sum)

"""
result for 'tamika phai mills' = 154
"""
[/php]
May 'the Google' be with you!
Quick reply to this message  
Join Date: Feb 2006
Posts: 43
Reputation: butterflyTee is an unknown quantity at this point 
Solved Threads: 0
butterflyTee butterflyTee is offline Offline
Light Poster

Re: I Need Help Please Writing This Program

 
0
  #6
Feb 23rd, 2006
Thanks A Lot For Your Help
Quick reply to this message  
Join Date: Feb 2006
Posts: 43
Reputation: butterflyTee is an unknown quantity at this point 
Solved Threads: 0
butterflyTee butterflyTee is offline Offline
Light Poster

Re: I Need Help Please Writing This Program

 
0
  #7
Feb 23rd, 2006
Thanks For Your Help
Quick reply to this message  
Join Date: Feb 2006
Posts: 43
Reputation: butterflyTee is an unknown quantity at this point 
Solved Threads: 0
butterflyTee butterflyTee is offline Offline
Light Poster

Re: I Need Help Please Writing This Program

 
0
  #8
Feb 23rd, 2006
Thanks
Quick reply to this message  
Join Date: Feb 2006
Posts: 43
Reputation: butterflyTee is an unknown quantity at this point 
Solved Threads: 0
butterflyTee butterflyTee is offline Offline
Light Poster

Re: I Need Help Please Writing This Program

 
0
  #9
Feb 23rd, 2006
Thank You
Quick reply to this message  
Join Date: Feb 2002
Posts: 12,047
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 129
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is offline Offline
The Queen of DaniWeb

Re: I Need Help Please Writing This Program

 
0
  #10
Feb 23rd, 2006
I think you're a little overanxious, butterflyTee. There is no need to keep bumping your thread with multiple posts. Additionally, I had to delete one of your threads because you posted in duplicate.
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/DaniWeb
And if you're interested in Internet marketing there is twitter.com/DaniWebAds
Quick reply to this message  
Closed Thread

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC