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
murzikaleks [220]
3 years ago
11

#Write a function called alter_list. alter_list should have#two parameters: a list of strings and a list of integers.##The list

of integers will represent indices for the list of#strings. alter_list should alter the capitalization of all#the words at the designated indices. If the word was all#capitals, it should become all lower case. If it was all#lower case, it should become all capitals. You may assume#that the words will already be all-caps or all-lower case.##For example:## string_list = ["hello", "WORLD", "HOW", "are", "you"]# index_list = [0, 2]# alter_list(string_list, index_list) -> # ["HELLO", "WORLD", "how", "are", "you"]##After calling alter_list, the strings at indices 0 and 2#have switched their capitalization. ##Note that it may be the case that the same index is present#in the second twice. If this happens, you should switch the#text at that index twice. For example:## string_list = ["hello", "WORLD", "HOW", "are", "you"]# index_list = [0, 2, 2]# alter_list(string_list, index_list) -> # ["HELLO", "WORLD", "HOW", "are", "you"]##2 is in index_list twice, so the string at index 2 is#switched twice: capitals to lower case, then back to#capitals.#Write your function here!#Below are some lines of code that will test your function.#You can change the value of the variable(s) to test your#function with different inputs.##If your function works correctly, this will originally#print:#["hello", "WORLD", "HOW", "are", "you"]#["HELLO", "WORLD", "HOW", "are", "you"]print(alter_list(["hello", "WORLD", "HOW", "are", "you"], [0, 2]))print(alter_list(["hello", "WORLD", "HOW", "are", "you"], [0, 2, 2]))
Computers and Technology
1 answer:
Aleks04 [339]3 years ago
7 0

Answer:

The Python code is given below with appropriate comments

Explanation:

def alter_list(strings,index):

   

   for i in index:

       s = strings[i]

       if s.islower():  #checking if lowercase

           strings[i] = s.upper()  #assigning variable in strings to uppercase in s

           

       if s.isupper():  #checking if uppercase

           strings[i] = s.lower()  #assigning variable in strings to lowercase in s

   return strings  #returns strings for the function

           

print(alter_list(["hello", "WORLD", "HOW", "are", "you"], [0, 2]))

print(alter_list(["hello", "WORLD", "HOW", "are", "you"], [0, 2, 2]))

You might be interested in
You are trying to troubleshoot a desktop power supply issue using a voltmeter. Which of the following options are the MOST commo
vredina [299]

Answer:

The correct answers are: (A) +/- 5V and (B) +/- 12V

Explanation:

First at all, the purpose of the power supply is transforming from AC (Alternating Current) to DC (Direct Current) for use this energy in chips and electronics devices that consume this type of power. Usually the most common DC voltage for electronics is 5V but in your CPU you also have other devices that might going to need more voltage like fan or hard drives thats ´s why 12V is an also an option. Now some other devices are going to need negative sources such -5V or -12V as well.

7 0
3 years ago
What happens when a filter is applied to a database
IgorLugansk [536]
<span>(A) All records that don't meet the criteria are removed
</span>
6 0
3 years ago
Keeping in mind the role the order of precedence plays in equations, what would Excel display as the result of the following equ
emmasim [6.3K]
The correct answer for the question that is being presented above is this one: "5.5" <span>Keeping in mind the role the order of precedence plays in equations, Excel would display as the result of the following equation? =(24+75)/(6*3): 5.5.</span>

5 0
3 years ago
Please name the OOP term that allows children classes to have methods with the same names as methods in their parents.
RSB [31]

Answer:

Inheritance

Explanation:

3 0
3 years ago
Tim has an old server computer that his company uses as a backup. One of the hard drives has gone bad and needs to be replaced.
dimaraw [331]

Answer:

SCSI.

Explanation:

It is a set of ANSI-developed simultaneous interface requirements for connecting scanners, drives, printers, and many other devices to systems.

Although when Tim has such an outdated network system which is used as a backup by his corporation. Then hard drive may have gone wrong and required replacement. The connector used by the hard disk drive is not something he has ever seen before, but he upload photos of that on the community board of the organization to aid determine what kind of hard disk drive they will also have to order.

So, according to the following scenario he required SCSI cable.

4 0
3 years ago
Other questions:
  • Write a program that uses for loops to perform the following steps: Prompt the user to input two integers: firstNum and secondNu
    15·1 answer
  • What kind of information B2B SaaS companies wish to know about their competition, apart from information about their competitors
    15·1 answer
  • Which following is one of the basic characters of object-oriented systems : Select one: a. process b. data c. module d. inherita
    6·1 answer
  • ALGUEM SABE COMO MUDA O NOME DE PERFIL!?!?!? SE SOUBER ME AJUDA!!
    14·1 answer
  • What is the main purpose of a graphic organizer?
    10·2 answers
  • How have productivity programs improved the professional lives of people? (check all that apply)
    8·2 answers
  • Design 3 classes: Computer - Superclass
    11·1 answer
  • Keli is unable to find a shape that meets her needs. Which feature in Power Point should she use to create shapes that are compl
    6·1 answer
  • HELP PLEASE !!!!!!!!!!!! Amy needs to ensure that she can enter a parameter that will match the values End, deadend, and flatend
    8·1 answer
  • Explain the steps in starting the MS Access from the Start Menu.​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!