Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 2 out of 12 pages
Exam (elaborations)

CMN 152V POST-MIDTERM EXAM QUESTIONS WITH CORRECT ANSWERS LATEST UPDATE 2026

Document preview thumbnail
Preview 2 out of 12 pages

CMN 152V POST-MIDTERM EXAM QUESTIONS WITH CORRECT ANSWERS LATEST UPDATE 2026 loopcond1 — try it For ages below, which version of over21 will run without producing an error? ages = [ 18, 24, 22, 17, 20, 21, 19, 18, 20, 25 ] over21_1 = [ (age 21) for age in ages ] over21_2 = [ age for age in ages if (age 21)] over21_1 over21_2 Both Neither - Answers both loopcond2 — try it For ages below, which version of over21 will produce a list of numbers? ages = [ 18, 24, 22, 17, 20, 21, 19, 18, 20, 25 ] over21_1 = [ (age 21) for age in ages ] over21_2 = [ age for age in ages if (age 21)] over21_1 over21_2 Both Neither - Answers over21_2 loopcond3 — try it For ages below, which version of over21 will produce a list as long as ages? ages = [ 18, 24, 22, 17, 20, 21, 19, 18, 20, 25 ] over21_1 = [ (age 21) for age in ages ] over21_2 = [ age for age in ages if (age 21)] over21_1 over21_2 Both Neither - Answers over21_1 loopcond4 — try it Select the option that will produce a list equal to outlist from list inlist inlist = [ 'pinch', 'punch', 'paunch', 'inch', 'cinch', 'wrench' ] outlist = [ 'pinch', 'inch', 'cinch'] 1 [ aword[-5:] == 'inch' for aword in inlist ] 2 [ aword[-4:] == 'inch' for aword in inlist ] 3 [ inchword for inchword in inlist if inchword[-5:] == 'inch' ] 4 [ inchword for inchword in inlist if inchword[-4:] == 'inch' ] 5 [ inch[-5:] for inch in inlist if inch[-5:] == 'nch' ] 6 [ inch[-4:] for inch in inlist if inch[-4:] == 'nch' ] 7 None of the above - Answers 4 loopcond5 — try it Select the option that will not produce a list equal to outlist from list inlist inlist = [ 'pinch', 'punch', 'paunch', 'inch', 'cinch', 'wrench' ] outlist = [ 'pinch', 'punch', 'paunch', 'inch', 'cinch', 'wrench' ] 1 [ element for element in inlist if element[-5:-1] == 'inch' ] 2 [ words for words in inlist ] 3 [ val[:] for val in inlist ] - Answers 1 loopcond6 — try it Select the option that will produce a list equal to outlist from list inlist inlist = [ 'aardvark', 'apogee', 'ape', 'open', 'oar', 'ocean' ] outlist = [ 'aardvark', 'oar' ] 1 [ item[2] == 'a' for item in inlist] 2 [ item for item in inlist if item[0] == 'a' ] 3 [ item for item in inlist if item[1] == 'a' ] 4 [ item for item in inlist if item[2] == 'a' ] 5 None of the above - Answers 3 loopcond7 — try it Select the option that shows the value of list cantvote ages = [ 5, 16, 18, 22, 26, 22, 19, 30, 17, 13, 20, 10 ] cantvote = [ age for age in ages if age 18 ] candrivecantvote = [ age for age in ages if age = 16 ] print( candrivecantvote ) 1 [ 5, 16, 18, 22, 26, 22, 19, 30, 17, 13, 20, 10 ] 2 [ 5, 16, 18, 19, 17, 13, 10 ] 3 [ 5, 16, 18, 17, 13, 10 ] 4 None of the above - Answers 4 loopcond8 — try it Select the option that shows the value of list candrivecantvote ages = [ 5, 16, 18, 22, 26, 22, 19, 30, 17, 13, 20, 10 ]

Content preview

CMN 152V POST-MIDTERM EXAM QUESTIONS WITH CORRECT ANSWERS LATEST UPDATE 2026

loopcond1 — try it
For ages below, which version of over21 will run without producing an error?
ages = [ 18, 24, 22, 17, 20, 21, 19, 18, 20, 25 ]
over21_1 = [ (age > 21) for age in ages ]
over21_2 = [ age for age in ages if (age > 21)]

over21_1
over21_2
Both
Neither - Answers both
loopcond2 — try it
For ages below, which version of over21 will produce a list of numbers?
ages = [ 18, 24, 22, 17, 20, 21, 19, 18, 20, 25 ]
over21_1 = [ (age > 21) for age in ages ]
over21_2 = [ age for age in ages if (age > 21)]

over21_1
over21_2
Both
Neither - Answers over21_2
loopcond3 — try it
For ages below, which version of over21 will produce a list as long as ages?
ages = [ 18, 24, 22, 17, 20, 21, 19, 18, 20, 25 ]
over21_1 = [ (age > 21) for age in ages ]
over21_2 = [ age for age in ages if (age > 21)]

over21_1
over21_2
Both
Neither - Answers over21_1
loopcond4 — try it
Select the option that will produce a list equal to outlist from list inlist
inlist = [ 'pinch', 'punch', 'paunch', 'inch', 'cinch', 'wrench' ]
outlist = [ 'pinch', 'inch', 'cinch']

1 [ aword[-5:] == 'inch' for aword in inlist ]
2 [ aword[-4:] == 'inch' for aword in inlist ]
3 [ inchword for inchword in inlist if inchword[-5:] == 'inch' ]
4 [ inchword for inchword in inlist if inchword[-4:] == 'inch' ]
5 [ inch[-5:] for inch in inlist if inch[-5:] == 'nch' ]
6 [ inch[-4:] for inch in inlist if inch[-4:] == 'nch' ]
7 None of the above - Answers 4
loopcond5 — try it
Select the option that will not produce a list equal to outlist from list inlist
inlist = [ 'pinch', 'punch', 'paunch', 'inch', 'cinch', 'wrench' ]
outlist = [ 'pinch', 'punch', 'paunch', 'inch', 'cinch', 'wrench' ]

1 [ element for element in inlist if element[-5:-1] == 'inch' ]
2 [ words for words in inlist ]
3 [ val[:] for val in inlist ] - Answers 1
loopcond6 — try it
Select the option that will produce a list equal to outlist from list inlist
inlist = [ 'aardvark', 'apogee', 'ape', 'open', 'oar', 'ocean' ]
outlist = [ 'aardvark', 'oar' ]

, 1 [ item[2] == 'a' for item in inlist]
2 [ item for item in inlist if item[0] == 'a' ]
3 [ item for item in inlist if item[1] == 'a' ]
4 [ item for item in inlist if item[2] == 'a' ]
5 None of the above - Answers 3
loopcond7 — try it
Select the option that shows the value of list cantvote
ages = [ 5, 16, 18, 22, 26, 22, 19, 30, 17, 13, 20, 10 ]
cantvote = [ age for age in ages if age < 18 ]
candrivecantvote = [ age for age in ages if age >= 16 ]
print( candrivecantvote )

1 [ 5, 16, 18, 22, 26, 22, 19, 30, 17, 13, 20, 10 ]
2 [ 5, 16, 18, 19, 17, 13, 10 ]
3 [ 5, 16, 18, 17, 13, 10 ]
4 None of the above - Answers 4
loopcond8 — try it
Select the option that shows the value of list candrivecantvote
ages = [ 5, 16, 18, 22, 26, 22, 19, 30, 17, 13, 20, 10 ]
cantvote = [ age for age in ages if age < 18 ]
candrivecantvote = [ age for age in ages if age >= 16 ]
print( candrivecantvote )

[ 5, 16, 18, 22, 26, 22, 19, 30, 17, 13, 20, 10 ]
[ 5, 16, 18, 19, 17, 13, 10 ]
[ 5, 16, 18, 17, 13, 10 ]
[ 16, 17, 13 ]
[ 16, 17 ]
[ 16 ]
None of the above - Answers none of the above
iflong1 — try it
Select the option that shows the number of lines of printed output that will be produced by the code
below.
weather = 'sunny'
if weather != 'sunny':
print( 'Might need raincoat' )

1
2
3
4
5
0
Error - Answers 0
iflong2 — try it
Select the option that shows the number of lines of printed output that will be produced by the code
below.
if True
print( 'This gets printed' )

1
2
3
4
5
0
Error - Answers error

Document information

Uploaded on
February 2, 2026
Number of pages
12
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$11.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.
joshuawesonga22
3.4
(12)
Sold
114
Followers
2
Items
15009
Last sold
1 week 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