The abbreviation should consist of the first character of the first name, followed by a dot and space, the first character of the middle name followed by a dot and space, and finally, the last name as is.Input format :The input consists of three strings, each representing the first name (fname), middle name (mname), and last name (lname) of a student.Each name is a sequence of non-space charactersOutput format :The output displays a single string representing the alphabetical abbreviation of the student's name.Refer to the sample output for the formatting specifications.Code constraints :In this scenario, the test cases will fall under the following constraints:The length of each name (fname, mname, lname) is at most 19 characters.The names consist only of alphabetical characters (a-z, A-Z).
Question
The abbreviation should consist of the first character of the first name, followed by a dot and space, the first character of the middle name followed by a dot and space, and finally, the last name as is.Input format :The input consists of three strings, each representing the first name (fname), middle name (mname), and last name (lname) of a student.Each name is a sequence of non-space charactersOutput format :The output displays a single string representing the alphabetical abbreviation of the student's name.Refer to the sample output for the formatting specifications.Code constraints :In this scenario, the test cases will fall under the following constraints:The length of each name (fname, mname, lname) is at most 19 characters.The names consist only of alphabetical characters (a-z, A-Z).
Solution
It seems like you want to create an abbreviation from a full name. Here's a step-by-step guide on how to do it in Python:
- First, you need to get the first name, middle name, and last name as input. You can use the
input()function in Python to get user input. Here's how you can do it:
fname = input("Enter first name: ")
mname = input("Enter middle name: ")
lname = input("Enter last name: ")
- Next, you need to get the first character from the first name and the middle name. You can do this by using indexing in Python. Here's how you can do it:
f_initial = fname[0]
m_initial = mname[0]
- Now, you need to create the abbreviation. The abbreviation should consist of the first character of the first name, followed by a dot and space, the first character of the middle name followed by a dot and space, and finally, the last name as is. You can do this by using string concatenation in Python. Here's how you can do it:
abbreviation = f_initial + ". " + m_initial + ". " +
Similar Questions
Write a function that reads your name in lowercase and perform the following operationprints it in uppercaseprints the length of the nameSample Inputsanjay kumarSample Outputramuk yajnas12
Arun is learning C language. His first program is to print his name in the console with proper spacing and spelling. Help him to achieve the task.Input format :No console input.Output format :The output displays the name as follows: "My Name is Arun."
Generate a list of the Instructor names by combining "Professor " and the first name, 1 space, and last name togethe
Write a function that reads your name in lowercase and perform the following operationprints it in uppercaseprints the length of the name
You have to create a struct, named Student, representing the student's details, as mentioned above, and store the data of a student.Input FormatInput will consist of four lines.The first line will contain an integer, representing age.The second line will contain a string, consisting of lower-case Latin characters ('a'-'z'), representing the first_name of a student.The third line will contain another string, consisting of lower-case Latin characters ('a'-'z'), representing the last_name of a student.The fourth line will contain an integer, representing the standard of student.Note: The number of characters in first_name and last_name will not exceed 50.Output FormatOutput will be of a single line, consisting of age, first_name, last_name and standard, each separated by one white space.P.S.: I/O will be handled by HackerRank.Sample Input15johncarmack10Sample Output15 john carmack 10
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.