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
Goryan [66]
4 years ago
14

Name format Many documents use a specific format for a person's name. Write a program whose input is: firstName middleName lastN

ame, and whose output is: lastName, firstName middle Initial. 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. If the input is: Julia Clark, the output is: Clark, Julia Note: This lab focuses on strings; using a loop is not necessary.

Computers and Technology
2 answers:
Nina [5.8K]4 years ago
8 0

Answer:

  1. inputName = input("Input your name: ")
  2. nameComp = inputName.split(" ")  
  3. if(len(nameComp) == 3):
  4.    print(nameComp[2] + ", " + nameComp[0] + " " + nameComp[1][0])
  5. elif(len(nameComp) == 2):
  6.    print(nameComp[1] + ", " + nameComp[0])
  7. else:
  8.    print("Invalid name")

Explanation:

The solution code is written in Python 3.

Firstly use input function to prompt user to enter a name (Line 1).

Next, use split method to divide the input name into a list of individual name components (first name, middle name and last name) by using a single space " " as separator (Line 2).

If the length of nameComp is equal to 3 (this means the input name consists of first, middle and last name), print the name in form of lastName, firstName and middle Initial. This can be done by using appropriate index to get the target name component from the nameComp list and reorder them in the print statement (Line 4-5).

If the nameComp is equal to 2 (this means input name only consists of first name and last name), use the similar way as above to use index to get the target name component from the nameComp list and reroder them in the print statement (Line 6-7).

Add one more else condition to handle the situation where invalid name is enter (Line 8-9).

steposvetlana [31]4 years ago
5 0

Answer:

Explanation:

def name(nameString):

   l = nameString.split(' ')

   if len(l)==3:

       firstName=l[0]

       middleName = l[1]

       lastName=l[2]

   else:

       firstName=l[0]

       lastName=l[1]

       middleName=""

   nameFormat=""

   if middleName!="":

       nameFormat = lastName+", "+firstName+", "+middleName[0]+"."

   else:

       nameFormat = lastName+", "+firstName

   return nameFormat

print(name("Pat Silly Doe"))

print(name("Julia Clark"))

You might be interested in
Exposing employee and customer personal data to an untrusted environment is an example of:
jonny [76]

Answer:

data breach

Explanation:

A data breach is a security event in which a unauthorized person steals, copy, access or transfer personal or confidential data. A data breach is the deliberate or unintentional leak of sensitive data into an distrusted environment. When a perpetrator or cyber criminal effectively invades a data source and steals confidential information, a data breach happens. This can be achieved physically by manipulating a device or network to steal or hack local data. Data breach is being used to target companies mostly by remotely bypassing network security.Data breaches include financial and personal information, trade secrets of companies or intellectual property, files, confidential documents etc.

8 0
3 years ago
what's the best mouse for fast clicking ? I play a lot of fps and a lot of pvp games I need a mouse that I can click fast with a
kondaur [170]
Alenware hp dell logtech, and i know others
7 0
3 years ago
Match each of the following terms to its definition:
Bingel [31]

I=B

II=C

III=E

IV=D

V=A

I have to write a bunch of extra things otherwise it won't let me post the answer lol.

7 0
3 years ago
What is the output of this program ? Assume the user enters 3,6 and 11​
Nostrana [21]

Answer:

C++

Explanation:

C++ Standards

C++ is standardized as ISO/IEC 14882. Currently, there are two versions:

C++98 (ISO/IEC 14882:1998): First standard version of C++.

C++03 (ISO/IEC 14882:2003): minor "bug-fix" to C++98 with no change to the language. Commonly refer to as C++98/C++03 or First C++ standard.

C++11 (ISO/IEC 14882:2011): Second standard version of C++. Informally called C++0x, as it was expected to finalize in 200x but was not released until 2011. It adds some new features to the language; more significantly, it greatly extends the C++ standard library and standard template library (STL).

C++14: Infomally called C++1y, is a small extension to C++11, with bug fixes and small improvement.

C++17: informally called C++1z.

C++2a: the next planned standard in 2020.

C++ Features

C++ is C. C++ supports (almost) all the features of C. Like C, C++ allows programmers to manage the memory directly, so as to develop efficient programs.

C++ is OO. C++ enhances the procedural-oriented C language with the object-oriented extension. The OO extension facilitates design, reuse and maintenance for complex software.

Template C++. C++ introduces generic programming, via the so-called template. You can apply the same algorithm to different data types.

STL. C++ provides a huge set of reusable standard libraries, in particular, the Standard Template Library (STL).

C++ Strength and Pitfall

C++ is a powerful language for high-performance applications, including writing operating systems and their subsystems, games and animation. C++ is also a complex and difficult programming language, which is really not meant for dummies. For example, to effectively use the C++ Standard Template Library (STL), you need to understand these difficult concepts: pointers, references, operator overloading and template, on top of the object-oriented programming concepts such as classes and objects, inheritance and polymorphism; and the traditional constructs such as decision and loop. C++ is performance centric. The C++ compiler does not issue warning/error message for many obvious programming mistakes, undefined and unspecified behaviors, such as array index out of range, using an uninitialized variable, etc, due to the focus on performance and efficiency rather than the ease of use - it assumes that those who choose to program in C++ are not dummies.

6 0
3 years ago
An independent penetration testing company is invited to test a company's legacy banking application developed for Android phone
erastovalidia [21]

2010s is the one who created the iPhone

8 0
3 years ago
Other questions:
  • If a security officer is non-commissioned officer, he can carry a baton on duty if he went through a training class
    8·1 answer
  • Many computer users and some operating systems call subdirectories ____.
    10·1 answer
  • John just opened a savings account and wants to maximize the account of interest you earn which of the following actions would e
    13·1 answer
  • John, the Network Administrator of XYZ Corporation, is interested in changing the format of text from American Standard Code for
    12·1 answer
  • When a crash results in property damages of any amount, the driver must notify:
    10·1 answer
  • One of the most common causes of fires in the home and workplace is: a. All of the answer choices b. Arson c. Candle d. Faulty e
    6·1 answer
  • Help me for this question
    8·1 answer
  • Original list:0,0,0,0,0,0,0,0
    10·1 answer
  • How i simplify this boolean expression ?A'.B'.C'+A'.B'.C+A'.B.C+A.B'.C+A.B.C
    6·2 answers
  • ________ programs help solve the problem of running out of storage space by providing lists of application programs, stored vide
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!