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]
4 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]4 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
Would increasing your ROM, increase the efficiency of a computer system.
Komok [63]

Answer:

The answer to this question is given below in the explanation section.

Explanation:

Increasing ROM (Read Only Memory) in your computer does not increase efficiency or improve the performance of your system. ROM is typically used to hold programs and data that do not change very frequently (if at all) and they typically survive power loss to the system. Increasing ROM does not increase the speed of CPU performance.

However, it is noted that increasing RAM (Random Access Memory) can increase the overall efficiency of the system and it also improves the performance of CPU speed. As you add more RAM to your system, it will increase the speed of CPU as you added more RAM into the system. Adding more ROM  could reduce the amount of a program that is installed on a slower disk or other external memory devices.

3 0
3 years ago
P6. In step 4 of the CSMA/CA protocol, a station that successfully transmits a frame begins the CSMA/CA protocol for a second fr
Karo-lina-s [1.5K]

Answer:

To avoid collision of transmitting frames.

Explanation:

CSMA/CA, carrier sense multiple access is a media access control protocol of wireless networks that allows for exclusive transmission of frames and avoidance of collision in the network. When a frame is not being sent, nodes listening for an idle channel gets their chance. It sends a request to send (RTS) message to the access point. If the request is granted, the access point sends a clear to send (CTS) message to the node, then the node can transmit its frame.

Many nodes on a wireless network are listening to transmit frames, when a frame is transmitting, the node has to wait for the access point to finish transmitting, so it sends a RTS message again to exclusively transmit a second frame.

8 0
4 years ago
What is the full form of ARPANet, WAN,FTP,DCP,HTML,ISP and last WWW​
Lapatulllka [165]

Advanced Research Projects Agency Network,

wide area network

File Transfer Protocol

?

Hypertext Markup Language

Internet service provider

world wide web

6 0
3 years ago
Read 2 more answers
Is this website real? Or is it a scam?
nikitadnepr [17]

It's a scam don't buy something

5 0
3 years ago
What are the 6 example of computer hardware​
zheka24 [161]

Answer:

Monitor.

Motherboard.

CPU(Microprocessor.

Main memory(RAM)

Expansion cards.

Power supply unit.

Explanation:

7 0
3 years ago
Read 2 more answers
Other questions:
  • When Twitter is used to gather a large group for a face-to-face meeting it is called a
    10·1 answer
  • Which of the following are examples of how a company might use consumer data it had collected? a To decide what types of product
    10·1 answer
  • What are three metrics used to define consistent network application availability?
    5·1 answer
  • How many feet are in 69 inches
    15·1 answer
  • How do productivity programs most benefit the way we work and live?
    12·2 answers
  • Which of these is not an application software?
    6·2 answers
  • Please help me with this this is Computer chapter Advanced HTML of class 8th​
    10·1 answer
  • Which of the following is the best way to remember the points you want to make during the presentation of your slide show?
    5·1 answer
  • Using AI to filter potential job applicants might be considered _____
    11·2 answers
  • Consider the following method:
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!