• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 10 pages
Exam (elaborations)

ITS Python Practice Exam 2 - Python Programming with Complete Solutions

Document preview thumbnail
Preview 2 out of 10 pages

ITS Python Practice Exam 2 - Python Programming with Complete Solutions

Content preview

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'}

Document information

Uploaded on
May 17, 2025
Number of pages
10
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$14.49

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
CLOUNDLite
4.0
(131)
Sold
666
Followers
389
Items
12415
Last sold
22 hours ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions