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]
4 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]4 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
the first thing to do when your computer gives you an error message is A restart the computer B press the F2 key C write down th
lesya692 [45]

Answer:

I think you should restart the computer

6 0
1 year ago
1.6.1: Identifier validator. Check if the following identifiers are valid: c, cat, n1m1, short1, _hello, 42c, hi there, and cat!
pogonyaev

Answer:

correct option c, cat, n1m1, short1,

Explanation:

correct option c, cat, n1m1, short1,

The variable is used to store the value of the value varies during the program execution...

some of the basic rules of identifier

  • The variable must be started with the alphabet  
  • We cannot declare the variable name as keyword i.e "that value is already defined and in the compiler"
  • Variable-length does not exceed 8 characters  
  • We cannot use space to declared any variable
  • _hello,42C, hi there and cat! are not follow the basic rule of identifier so they are not identifier validator
5 0
4 years ago
Which form of measurement is the largest?
nlexa [21]
Gigabyte is the correct answer
8 0
3 years ago
Read 2 more answers
Define a function pyramid_volume with parameters base_length, base_width, and pyramid_height, that returns the volume of a pyram
jok3333 [9.3K]

Answer:

def pyramid_volume(base_length,base_width,pyramid_height):

      return base_length * base_width * pyramid_height/3

length = float(input("Length: "))

width = float(input("Width: "))

height = float(input("Height: "))

print("{:.2f}".format(pyramid_volume(length,width,height)))

Explanation:

This line declares the function along with the three parameters

def pyramid_volume(base_length,base_width,pyramid_height):

This line returns the volume of the pyramid

      return base_length * base_width * pyramid_height/3

The main starts here

The next three lines gets user inputs for length, width and height

<em>length = float(input("Length: "))</em>

<em>width = float(input("Width: "))</em>

<em>height = float(input("Height: "))</em>

This line returns the volume of the pyramid in 2 decimal places

print("{:.2f}".format(pyramid_volume(length,width,height)))

5 0
4 years ago
What is output by the following code?
Marysya12 [62]
Division in Java will return the integer value and disregard the remainder. This line of code will return 4.

:)
3 0
4 years ago
Other questions:
  • What is the ratio between total bits required for such a cache implementation over the data storage bits?
    10·1 answer
  • Create your own unique Java application to read all data from the file echoing the data to standard output. After all data has b
    13·1 answer
  • You should click ____ in the category list on the number sheet in the format cells dialog box to select or create a format code.
    14·1 answer
  • What careers are most likely to require business skills
    13·1 answer
  • CodeHS 3.4.5. What is the code for four colored triangles.
    8·1 answer
  • Organizations should communicate with system users throughout the development of the security program, letting them know that ch
    12·1 answer
  • Somebody supplied me with a file that was edited on a Windows machine. The file contains carriage returns in addition to the new
    9·1 answer
  • The Brinley website will not let me search for questions anymore. It says “Search all you want in-app” and then covers the quest
    14·1 answer
  • Open excel program then use the (IF) function to fill the column of (Expensive/Cheap) then save your
    9·1 answer
  • Write a code segment that will store a dinner selection in option1 based on the values of rsvp and selection. The intended behav
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!