Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Based in Python 3.5.1 Numerology is the \"study of the purported mystical or spe

ID: 3686693 • Letter: B

Question

Based in Python 3.5.1

Numerology is the "study of the purported mystical or special relationship between a number and observed or perceived events." It has been used throughout human history as a way to attach meaning to a name, object or event using mathematics. It is considered a "pseudoscience" by modern scientists since it has no basis in observable phenomena. With that said, it makes a great programming challenge so we're going to go with it! :)

What you want to do for this project is to ask the user to type in their name. Next, you will need to use a technique called "theosophical reduction" to convert their name into a number. With this technique we assign each letter of the alphabet its own number. For example, the letter "a" is equal to the number 1. "b" = 2, "c" = 3, "z" = 26, etc. You should ignore non-alphabetic characters (i.e. numbers, spaces and special characters)

Once you've gotten all of the letters converted into numbers you can add them up into one single number. This is the "numerology number" for the name that the user entered.

So for the name "craig" the numerology number would be:

Here's are a few sample runnings of this program:

Some hints:

Convert the user's name to all lowercase before you do anything else

Remove any spaces, numbers or special characters from the name to ensure that you are only working with the letters A-Z

The ord() function may be userful to convert each character into an ASCII index

Explanation / Answer

Please past this code in your editor. If we enter A !1 3&b then we see output according to your requirement.

Output :-

Name: A !1 3&b

Your 'cleaned up' name is: ab

Your 'cleaned up' name reduces to:

1 + 2 = 3

Code start here :-

import re

# this function use for convert each character into an ASCII index

def char_position(letter):

    index = ord(letter) - 97

    return index+1

# this function is used to perform conversion in lower and remove any spaces, numbers or special characters from the name

def numerology(name):

    try:

        # print orgianl value here

        print("Name: " + name)

        # convert all string in lowercase

        name = name.lower()

        #Remove any spaces, numbers or special characters from the name. we used reg for this action if you want change then change reg according to your requrement.

        name = re.sub('[^A-Za-z.]+', '', name)

        # show message after clean

        print("Your 'cleaned up' name is: " + name)

        total = 0

        # se loop for get char in string

        for i in range(len(name)):

            #get char index

            m = char_position(name[i])

            total = total+m   

            if(i==0):

                s_total = str(m)

            else:

                s_total = s_total+' + '+str(m)

       

        s_total = s_total+' = '+str(total)

        # show final message here

        return "Your 'cleaned up' name reduces to: " + s_total

    except:

        return 'Some thing worng.'

   

# ask user to input any string

name = input("What's your name? ")

print(numerology(name))

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote