1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
amid [387]
3 years ago
8

Many documents use a specific format for a person's name. Write a program whose input is: firstName middleName lastName, and who

se output is: lastName, firstName middleInitial. Ex: If the input is Pat Silly Doe, the output is: Doe, Pat S. If the input has the form firstName lastName, the output is lastName, firstName.
Computers and Technology
1 answer:
never [62]3 years ago
4 0

Answer:

Python Program:

if __name__ == '__main__':

   a = input("Enter Name: ")

   b = a.split()

   print(b[2] + ',' , b[0], b[1][0])

Explanation:

The input function will be used to prompt user to enter the name of the person. The person's name will be stored in variable a.

Let us assume that the user entered a name mentioned in the example, which is Pat Silly Doe, Now variable a = 'Pat Silly Doe'.

The function a.split() is used to split a string into a list. The splitting (by default) is done on the basis of white-space character. Therefore, a.split() will give a list

['Pat', 'Silly', 'Doe']

which will be later on stored in variable b.

We can use the subscript operator [] to access the values in a list. Suppose if we have a list a, then a[i] will give us ith element of a, if i < length of a.

Finally, we print the answer. b[2] will give us the last name of the person. We append a comma using '+' operator. b[0] will give us the first name. b[1] will give us the middle name, but since we only need one character from the middle name, we can use another subscript operator b[1][0] to give us the first character  of the middle name.

Note: Characters of strings can be accessed using subscript operator too.

You might be interested in
Create a paper of at least 1,800 words describing the situation you selected and explaining the logic that would support an arra
sleet_krkn [62]

Answer:

I dont know about 1800 words but I sure can tell you abit about array

Explanation: Array in simple sense refers to a collection of similar data. It holds data which is homogeneous in nature, meaning they are all alike. The use of array provide a lot of advantages in the fields of computer programming. When you declare a variable for an array, you can store as much data as you wish in the same variable without having to declare many variables. A 2X2 dimensional array can also be used in programming which represents matrices as well. The search process in an array too is really convenient and time saving. Also in an array, accessing an element is very easy by using the index number.

6 0
2 years ago
You can use this effect to break a color into a percentage of its full strength.
Dmitriy789 [7]
The answer on this scenario would then be c. drop out. This effect can be done if one wants to break a color into one's percentage of the full strength. Hope this is the answer and would be of big help.
6 0
3 years ago
Who invented computer ?​
liraira [26]

Answer:

Charles Babbage invented computer.

hope this helps!

8 0
2 years ago
Read 2 more answers
Which of the following choices is not a viewing option?
malfutka [58]
B. FILE PAGES 
I answered wrong the first time, but according to an exam the answer is B. Definitely trust an exam answer! 
7 0
3 years ago
How should you schedule a meeting with someone in another time zone?
gavmur [86]

If you know what timezone they're in, try to work out what time in your own timezone your free, then tell the other person to do the same. Tell them what times in your timezone and the other can search up what the time is in their own timezone. If there is a specific time when you are both free, use that.

Ex:

You live in the U.S. but you have a meeting with someone in the U.K. You're only free at 4:00pm-6:00pm and they're only free from 10:00am-11:00am. 11:00am in England is 4:00pm in the U.S. so do at that time!

Hope this helps!

7 0
2 years ago
Other questions:
  • Write a function SwapArrayEnds() that swaps the first and last elements of the function's array parameter. Ex: sortArray = {10,
    8·1 answer
  • In a system using the relocatable dynamic partitions scheme, given the following situation (and using decimal form): Job Q is lo
    5·1 answer
  • You want the user to enter the length, width, and height from the keyboard. Which cin statement is correctly written?
    10·1 answer
  • What is conference proceeding​
    10·2 answers
  • For a parking payment app, what option would MOST likely connect a user to a third party/external gateway?
    10·1 answer
  • Recently mobile phones have been used to pay for goods in stores and supermarkets. One method
    11·1 answer
  • The first page of a website is what?​
    5·2 answers
  • Hello everyone! can anybody help me? i need help with computing.
    10·1 answer
  • Explain the concept of conditional formatting​
    9·1 answer
  • Modern helps to convert analog signal into digital and vice verse. true of false​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!