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

Write a function called \"findUserName\" that displays a suggested username base

ID: 3667471 • Letter: W

Question

Write a function called "findUserName" that displays a suggested username based on a person's first name, last name, and birth year given as a single string "firstname lastname birthyear' (each separated by a single space, may contains both upper and lower case letters). The result should be the person's first name (all letters in lower case) followed by the last name (capitalized) and the sum of birth year plus number of characters of the first name. Note: Steps of findUserName function can be given as follow's: def findUserName (s) : 1. Separate first name, last name and birth year from string s 2. lowerFirst = Lower case first name 3. capitalizedLast = Capitalized last name 4. num = Integer value of birthYear + Number of characters of first name 5. Concatenate the substring in the order, lowerFirst, capitalizedLast and string value of num and display the result. For example, findUserName ("MARY TWEED 1992") would displays maryTweedl996. Save the script as "lab4_checkpoint2.py" in csl041ab4 folder.

Explanation / Answer

def findUserName(s) :
    values = s.split(" ")
    lowerFirst = values[0].lower()
    capitalizedLast = values[1].capitalize()
    num = int(values[2]) + len(values[0])
    print lowerFirst+capitalizedLast+str(num)
  


findUserName ("MARY TWEED 1992")

output : maryTweed1996

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