• ¿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 10 páginas
Examen

ITS Python Practice Exam 2 - Python Programming with Complete Solutions

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

ITS Python Practice Exam 2 - Python Programming with Complete Solutions

Vista previa del contenido

ITS Python Practice Exam 2 - Python
Programming with Complete Solutions
A developer is writing code to iterate prining and state, with the end result looking like
this:
Orange Florida
Orange Ohio
Orange Illinois
Springfield Florida
Springfield Ohio
Springfield Illinois
Capital
Auburn Florida
Auburn Ohio
Auburn Illinois
The first two lines of code are as follows:
cities=["Orange","Springfield","Auburn"]
states=["Florida","Ohio","Illinois"]

Using the dropdown arrows, complete the code necessary to generate the above
output. - ANSWER-for x in cities:
for y in states:
if x=="Springfield" and y=="Illionois":

A developer wants documentation for a function to display when called upon in a print
statement. Use the drop-down menus to fill in the remainder of the code necessary to
generate the documentation. - ANSWER-'''
'''
area.__doc__

A developer wants to print the first line of a configuartion file. The code to perform this
tast is written as follows:
#import module
if os.path.isfile('config.txt;):
with open('config.txt','r') as file:
print(file.#read the first line)

Which code snippets are needed to replace the comments and finish this code
example? - ANSWER-readline()
import. os.path

A junior programmer enters the following code:
height=5
width=5

, if height==width
print("You have a square")

When trying to run the code, errors are generated. Which two fixes are necessary in
order for this code to work? - ANSWER-A colon needs to be added at the end of the if
condition.
The print statement needs to be indented.

A junior programmer is building a function to compute the area of a rectangle. Which
function definition statement is needed to replace the comment to make this code work?
#declare function here
z=x*y
print(z)
area(5,10) - ANSWER-def area(x,y):

A junior programmer writes the following code to store a list and then retrieve an item
from the list:
tees=['Douglas fir','Oak','Balsam fir']
last_tree=trees[3]
print(f'The last tree is {last_tree}.')

What type of error message (if this code generates an error) will this code produce? -
ANSWER-A runtime error

A new Python developer is learning the code necessary to display dates in multiple
formats. The developer has been tasked to create the following display with dates:
2023-01-01
The current date is 01/01/2023
The current weekday is: 6

Using the dropdown arrows, complete the code snippet necessary to create the display,
leaving open the possibility of the time being displayed in the future. - ANSWER-import
datetime
datetime,datetime.now()
%m/%d/%Y
weekday()

A new Python developer is trying to understand the differences among data structures.
Using drag and drop, match each code example with a characteristic of the type of list
being generated from the code. - ANSWER-
background_colors=['yellow','slate','lightblue']
locations={'HQ','West','Remote1'}
departments=('Sales','Marketing','Operations','IT')
offices={'location':'East','size':'4500'}

Información del documento

Subido en
17 de mayo de 2025
Número de páginas
10
Escrito en
2024/2025
Tipo
Examen
Contiene
Preguntas y respuestas
$14.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.
CLOUNDLite
3.9
(132)
Vendido
669
Seguidores
389
Artículos
12457
Última venta
1 día 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