• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 4 fuera de 31 páginas
Examen

Cit 332 Final || All Solved.

Document preview thumbnail
Vista previa 4 fuera de 31 páginas

Which of the following refer to the last element in a list names? Check all that apply. correct answers names[-1] names[len(names) - 1] Analyze the following code list1 = ['CS', 'Math', 'EE']major1, major2 = list1 which of the following statements are true? Check all that apply. correct answers There is an error because the number of variables on the left-hand side is different from the size of the list. Analyze the following code nums = [3, 7, 2, 1]print(len(nums))print(nums[-1])print(nums[len(nums)]) correct answers There is an IndexError on line 4. What is the output of the following code? list1 = [2, 3, 21, 14, 25]print(list1[-1]) correct answers 25 A list may have duplicates. correct answers TRUE Given list1 = [1, 5, 9], what is sum(list1)? correct answers 15 Which of the following statements create empty lists? correct answers li = [] li = list() Every element in a list must be of the same type? correct answers FALSE What is the output of the following code?

Vista previa del contenido

CIT 332 FINAL || ALL SOLVED.

Which of the following refer to the last element in a list names? Check all that apply. correct
answers names[-1]
names[len(names) - 1]


Analyze the following code
list1 = ['CS', 'Math', 'EE']major1, major2 = list1
which of the following statements are true? Check all that apply. correct answers There is an
error because the number of variables on the left-hand side is different from the size of the list.


Analyze the following code
nums = [3, 7, 2, 1]print(len(nums))print(nums[-1])print(nums[len(nums)]) correct answers There
is an IndexError on line 4.


What is the output of the following code?
list1 = [2, 3, 21, 14, 25]print(list1[-1]) correct answers 25


A list may have duplicates. correct answers TRUE


Given list1 = [1, 5, 9], what is sum(list1)? correct answers 15


Which of the following statements create empty lists? correct answers li = []
li = list()


Every element in a list must be of the same type? correct answers FALSE


What is the output of the following code?

,list1 = [3, 5, 25, 1, 3]print(min(list1)) correct answers 1


What's the output of the following code segment?
aList = [14, 55, 4, 34, 2, -3, 76]
index = 0
for i in range(1, len(aList)):
if ( aList[i] < aList[index] ):
index = i



print(index) correct answers 5


What is the output when following code is executed ?
listA = [-8, 3, 45, 22, 12, 85] for i in range (1, 6): listA[i - 1] = listA[i] *2 for i in range(0, 6):
print(listA[i], end = " ") correct answers 6 90 44 24 170 85


What is the output when the following code is executed?
myList = [-85, 34, 23, 90, 123]maximumValue = myList[0]indexOfMax = 0for i in range(1,
len(myList)): if (myList[i] > maximumValue): maximumValue = myList[i] indexOfMax = i
print(indexOfMax) correct answers 4


Given list1 is [1, 3, 2], what is the result of list1 * 2? correct answers [1, 3, 2, 1, 3, 2]


What is the output of the following code?
list1 = [1, 2, 3, 4]list2 = [5, 6, 7, 8] print(len(list1 + list2)) correct answers 8


What is printed by the following statements?
a = [4, 2, 8, 6, 5]b = a * 2b[3] = 999print(a) correct answers [4, 2, 8, 6, 5]

,What's the output of the following code?
a = [1, 2, 3, 4]b = [10, 20, 30, 40]c = a + bprint(c) correct answers [1, 2, 3, 4, 10, 20, 30, 40]


What is printed by the following statements?
a = [4, 2, 8, 6, 5]


b = [a] * 2
c=a*2


a[3] = 999


print(a)
print(b)
print(c) correct answers [4, 2, 8, 999, 5]
[[4, 2, 8, 999, 5], [4, 2, 8, 999, 5]]
[4, 2, 8, 6, 5, 4, 2, 8, 6, 5]


What is printed by the following statements?
alist = [3, 67, "cat", [56, 57, "dog"], [ ], 3.14, False]print(alist[4:]) correct answers [[], 3.14,
False]


What is the output of the following code?
studentsNames = ['Alex', 'Smith', 'William', 'Tom']if ('Smith' in studentsNames): print
("Found")else: print ("Not found") correct answers FOUND


Which of the following statement inserts 7 to the second position in list1? correct answers
list1.insert(1, 7)

, Which of the following statement removes the third element from list1? correct answers
list1.pop(2)


Which of the following statement removes string "python" from list1? correct answers
list1.remove("python")


What is the returned value from this function?
def example(L):
i=0
result = []
while (i < len (L)) :
result.append(L[i])
i=i+3
return result
# Call the above function as below
x = example ( [2,3,4.5,6,7,8,9,10,11,12] )
print (x) correct answers Returns a list containing every third item from L starting at index 0.


What is the output when the following function is called as below?
def function1 (values):
values[0] = 89
# Call the above function as below
list1 = [11, 12, 30]
function1(list1)
print (list1) correct answers [89, 12, 30]


What's the output from the following code segment:
def mid(vals):

Información del documento

Subido en
27 de mayo de 2025
Número de páginas
31
Escrito en
2024/2025
Tipo
Examen
Contiene
Preguntas y respuestas
$14.99

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
SirAnton
3.7
(118)
Vendido
807
Seguidores
438
Artículos
40070
Última venta
2 semanas hace



Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes