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
zhannawk [14.2K]
2 years ago
10

Modify short_names by deleting the first element and changing the last element to Joe. Sample output with input: 'Gertrude Sam A

nn Joseph'

Computers and Technology
1 answer:
notka56 [123]2 years ago
6 0

Answer:  

I am writing a Python program:

For taking input from user:

user_input = input() # takes input from user

short_names = user_input.split() #splits user_input into list of strings

short_names.pop(0) # removes the first element of the list i.e. Gertrude

short_names[-1] = "Joe" #sets the last element to Joe

print(short_names)    #prints modified list of Sam Ann Joe

If you do not want to take input from user:  

short_names=['Gertrude', 'Sam', 'Ann', 'Joseph']  #list of 4 elements

short_names=short_names[1:]  # removes the first element Gertrude

short_names.pop()  # removes last element i.e. Joseph from list

short_names.append('Joe')  #adds Joe to the end of the list

print(short_names) #prints modified list Sam Ann Joe

If you do not want to use pop() and append() methods:

short_names = ['Gertrude', 'Sam', 'Ann', 'Joseph']  #creates list of 4 values

short_names = short_names[1:]  # removes first value i.e. Gertrude from list

short_names[-1] = "Joe"  #set the last element to Joe

print(short_names) #prints modified list Sam Ann Joe

Explanation:

The first program takes the names from the user, splits them into list of strings, then pop(0) has given index value 0 which means 1st value in the list. So it removes and returns first value from the list. Next statement sets the last value of list to Joe.

The second program has a hard coded list ['Gertrude', 'Sam', 'Ann', 'Joseph']  

short_names = short_names[1:] removes the first value of the short_names list i.e. Gertrude. Next pop() removes and returns last value in the list i.e. Joseph from list. Last statement append('Joe') adds Joe to the end of the list.

The third program has a list of 4 elements. short_names = short_names[1:]   removes first value i.e. Gertrude from list and short_names[-1] = "Joe"  sets the last element to Joe.

You might be interested in
Four workers take an extra half-hour for lunch, at a cost of $14/ hour
Usimov [2.4K]

Answer:

whats the rest ?

Explanation:

whats the rest ?

8 0
3 years ago
You can use the ____ to change the order of the wat windows are stacked.
djyliett [7]

Answer:

A

Explanation:

6 0
2 years ago
Levi wants to run 5 commands sequentially, but does not want to create a shell script. He knows that each command is going to ta
disa [49]

Levi can use the bash command to type all the commands on the same line to type one after the other character without requiring input.

<u>Explanation</u>:

  • He wants to run five commands. For one command it will take exactly 20 minutes. So it will take one hour forty minutes.
  • To type all of the commands on the same line Levi should use the bash command. For inserting the bash command Levi should use backslash \ as the last character of the line.
6 0
3 years ago
How can you insert an image file in your word document?​
Margarita [4]

Click the insert tab, it'll show a pop up window. Go to the location of where your picture may be. Double click on the photo, and it will be inserted into the word document.

6 0
2 years ago
Thinking actively promotes critical thinking. Explain how thinking actively promotes critical thinking
pav-90 [236]

A critical thinker is someone who is actively engaged in a thought process. Active thinking is that process of making judgments about what has happened while critical thinking involves a wide range of thinking skills that eventually leads to a desired outcome. Active thinking prompts learning during complex problems situations and provides learners with an opportunity to think about how a problem will be solved. As a result, it will help them evaluate, analyze, and intercept information.

8 0
3 years ago
Other questions:
  • Write a program that allows the user to convert a temperature given in degrees from either Celsius to Fahrenheit or Fahrenheit t
    13·1 answer
  • What does LMS Date Updated mean?
    9·1 answer
  • Why are networked systems beneficial?
    9·2 answers
  • The default case is required in the switch selection statement.
    12·1 answer
  • Is it just me or is brainly not working right now? I am trying to add friends and it won't let me!
    5·2 answers
  • A security policy is a
    11·1 answer
  • A. Draw a flowchart or write pseudocode to represent the logic of a program that allows the user to enter an hourly pay rate and
    8·1 answer
  • Find the Nearest Repeated Entries in an Array People do not like reading text in which a word is used multiple times in a short
    15·1 answer
  • During which geologic era was nearly all of Earth's land concentrated into one giant mass called Pangaea?
    6·1 answer
  • Write a function (subroutine) that inputs a data value in register r0 and returns value in r0. The function returns y 5 a 1 bx 1
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!