• ¿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 2 fuera de 5 páginas
Examen

D522 - Coding Problems Question with Verified Correct Answers

Document preview thumbnail
Vista previa 2 fuera de 5 páginas

D522 - Coding Problems Question with Verified Correct Answers

Vista previa del contenido

D522 - Coding Problems Question with Verified
Correct Answers
Code Problem: Create a function named add_numbers that returns the sum of a and b.

Answer: def add_numbers(a, b):\n return a + b

Code Problem: Create a function named minutes_to_hours that converts minutes to

hours.

Answer: def minutes_to_hours(minutes):\n return minutes / 60

Code Problem: Create a function named is_adult that returns True if age is 18 or older.

Answer: def is_adult(age):\n return age >= 18

Code Problem: Create a function named check_temp that returns "Hot" if temp is

greater than 80, otherwise return "Not hot".

Answer: def check_temp(temp):\n if temp > 80:\n return "Hot"\n else:\n return "Not hot"

Code Problem: Create a function named check_access that returns "Allowed" only if

has_id is True and age is 18 or older.

Answer: def check_access(age, has_id):\n if age >= 18 and has_id == True:\n return

"Allowed"\n else:\n return "Denied"

Code Problem: Create a function named count_to_five that prints numbers 1 through 5

using a while loop.

Answer: def count_to_five():\n count = 1\n while count <= 5:\n print(count)\n count += 1

Code Problem: Create a function named get_high_values that returns values greater

than 90 from a list.

, Answer: def get_high_values(nums):\n high_values = []\n for num in nums:\n if num > 90:\n

high_values.append(num)\n return high_values

Code Problem: Create a function named get_high_indices that returns the indexes of

values greater than 90.

Answer: def get_high_indices(nums):\n indices = []\n for i in range(len(nums)):\n if nums[i]

> 90:\n indices.append(i)\n return indices

Code Problem: Create a function named first_item that returns the first item in a list.

Answer: def first_item(items):\n return items[0]

Code Problem: Create a function named last_item that returns the last item in a list.

Answer: def last_item(items):\n return items[-1]

Code Problem: Create a function named add_item that adds item to a list and returns

the updated list.

Answer: def add_item(items, item):\n items.append(item)\n return items

Code Problem: Create a function named update_name that changes the "name" value

in a dictionary.

Answer: def update_name(user, new_name):\n user["name"] = new_name\n return user

Code Problem: Create a function named get_status that returns the value stored under

the "status" key.

Answer: def get_status(log):\n return log["status"]

Code Problem: Create a function named format_rgb that accepts a list like [255, 0, 100]

and returns "rgb(255,0,100)".

Información del documento

Subido en
15 de septiembre de 2026
Número de páginas
5
Escrito en
2026/2027
Tipo
Examen
Contiene
Preguntas y respuestas
$11.49

¿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.
KenAli
2.6
(18)
Vendido
125
Seguidores
5
Artículos
26693
Última venta
4 días 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