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

1. Design a program that will accept the users name separated by blanks. The pro

ID: 3553683 • Letter: 1

Question

1.     Design a program that will accept the users name separated by blanks. The program then uses the information in the string to output the following. The bold words are an example of what the user puts in.

Welcome to the String manipulator program!

Please enter your full name separated by blanks: John Smith

Your initials are: JS

The length of your last name is: 5

Hey, shy about your middle name? It's probably very nice!

Want to do that again? (y for yes) y

Please enter your full name separated by blanks: John M Smith

Hello, John

Your initials are: JMS

The length of your last name is: 5

What does the M stand for???

Want to do that again? (y for yes) y

Please enter your full name separated by blanks: John Michael Smith

Hello, John

Your initials are: JMS

The length of your last name is: 5

I like Micheal for a middle name!

Want to do that again? (y for yes) n

Goodbye now!


This is what I have so far:

runProgram True

while(runProgram)

         print("Welcome to the string manipulator program!")

         print("Please enter you full name seperated by blanks")

Explanation / Answer

You can find the code here aswell: http://ideone.com/7nr4ix


print("Welcome to String manipulation program")
while(True):
    inputString=raw_input("Please enter your Full Name seperated by blanks:")
    name=inputString.split()
    if len(name)==2:
        firstName=name[0]
        lastName=name[1]
        print("Your initials are: "+firstName[0]+lastName[0])
        print("The length of your last name is: "+str(len(lastName)))
        print("Hey, shy about your middle name ?Its probably very nice!")
    else:
        firstName=name[0]
        middleName=name[1]
        lastName=name[2]
        if len(middleName)==1:
            print("Hello "+firstName)
            print("Your initials are: "+firstName[0]+middleName[0]+lastName[0])
            print("The length of your last name is: "+str(len(lastName)))
            print("What does the "+middleName+" stand for???")
        else :
            print("Hello "+firstName)
            print("Your initials are: "+firstName[0]+middleName[0]+lastName[0])
            print("The length of your last name is: "+str(len(lastName)))
            print("I like "+middleName+" for a middle name!")

    choice=raw_input("Want to do that again?(y for yes) ")
    if choice=="n":
        break