Problemas
3. wordList is a list of words that currently contains the values ["tree","rock","air'l Which of the following lines will result in the list containing the values ["air", "rock","airl A. wordList[O]=wordList[2] B. wordList[2]=wordList[0] C. insertitem(wordList,0,''air'') D. removeltem(wordList,0)
Solución
Sergioélite · Tutor durante 8 años
Verificación de expertos
4.4 (325 votos)
Responder
The correct answer is C. $insertitem(wordList,0,'air')$.<br /><br />Explanation:<br />The initial value of the wordList is ["tree", "rock", "air"]. To change the list to ["air", "rock", "air"], we need to insert the word "air" at the beginning of the list.<br /><br />Option A: $wordList[0]=wordList[2]$ will replace the first element with the third element, resulting in ["rock", "rock", "air"], which is not the desired output.<br /><br />Option B: $wordList[2]=wordList[0]$ will replace the third element with the first element, resulting in ["tree", "rock", "tree"], which is not the desired output.<br /><br />Option C: $insertitem(wordList,0,'air')$ will insert the word "air" at the beginning of the list, resulting in ["air", "rock", "air"], which is the desired output.<br /><br />Option D: $removeltem(wordList,0)$ will remove the first element from the list, resulting in ["rock", "air"], which is not the desired output.<br /><br />Therefore, the correct answer is option C.
Haz clic para calificar: