









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
ITS Python Practice Exam 1 - Python Programming questions with answers
Typology: Exams
1 / 17
This page cannot be seen from the preview
Don't miss anything!










Python |\makes |\the |\distinction |\between |\integers |\and |
floating |\variables. |- |\CORRECT |\ANSWERS |\✔✔Yes When |\declaring |\variables |\in |\Python, |\a |\data |\type |\must |\be |
specified. |- |\CORRECT |\ANSWERS |\✔✔No When |\setting |\a |\boolean |\variable, |\the |\value |\must |\start |
with |\a |\capital |\letter. |- |\CORRECT |\ANSWERS |\✔✔Yes A |\developer |\wants |\to |\make |\sure |\a |\serial |\number |\cannot |
be |\used |\in |\a |\calculation |\and |\that |\a |\dollar |\amount |\entered |
as |\a |\whole |\number |\can |\have |\decimals. |\Then, |\a |\message |
should |\be |\displayed |\to |\tell |\a |\customer |\the |\serial |\number |
and |\price |\for |\the |\products. |\Using |\the |\drop-down |\arrows, |
fill |\in |\the |\code |\to |\use |\the |\proper |\functions |\to |\convert |\the |
data |\to |\the |\necessary |\data |\types. |- |\CORRECT |\ANSWERS |
✔✔str float ,
A |\developer |\needs |\to |\write |\code |\to |\reverse |\the |\character |
output |\of |\a |\product |\code. |\Which |\variable |\declaration |\will |
reverse |\one |\of |\the |\product |\codes? |- |\CORRECT |\ANSWERS |
✔✔[::-1] In |\this |\scenario, |\the |\number |\of |\complete |\units |\needs |\to |
be |\displayed, |\meaning |\that |\anything |\after |\a |\decimal |\point |\needs |\to |\not |\be |\represented. |\To |\accomplish |\this, |\the |\int |
function |\is |\needed |\as |\it |\extracts |\the |\whole |\number |\from |\a |\value |\with |\a |\floating |\decimal. |\The |\round |\function |\will |\not |
work |\because |\it |\will |\round |\the |\number |\up |\to |\20. |\The |\floor |
function |\rounds |\a |\number |\down |\to |\the |\nearest |\integer. |
The |\ceil |\function |\will |\raise |\the |\number |\to |\20. |\The |\correct |
code |\is |\as |\follows: |- |\CORRECT |\ANSWERS |\✔✔int A |\developer |\needs |\to |\build |\a |\data |\structure |\with |\animals |
and |\then |\sort |\the |\structure. |\Using |\drag |\and |\drop, |\drag |\the |\following |\lines |\of |\code |\into |\the |\correct |\order |\to |\produce |
this |\output: Bears Jaguars Lions Panthers |- |\CORRECT |\ANSWERS |
✔✔animals=["Bears","Panthers","Lions"] animals.append("Jaguars") animals.sort()
else: |\print("You |\are |\doing |\well. |\Strive |\to |\improve") |- |
CORRECT |\ANSWERS |\✔✔==
= <= a__b= a__b= a__b=3. a__b= a__3=1 |- |\CORRECT |\ANSWERS |\✔✔+
/ // % a |== |\b |- |\CORRECT |\ANSWERS |\✔✔Yes a |\is |\b |- |\CORRECT |\ANSWERS |\✔✔Yes b |== |\ 3 |- |\CORRECT |\ANSWERS |\✔✔No c |\is |\b |- |\CORRECT |\ANSWERS |\✔✔No
Look |\at |\the |\following |\code |\and |\then |\select |\the |\correct |
keyword |\to |\use |\to |\check |\to |\see |\if |\the |\word |"nine" |\is |\part |
of |\the |\quote. |\If |\this |\code |\runs, |\it |\should |\return |\a |\value |\of |
True. |- |\CORRECT |\ANSWERS |\✔✔in Drag |\the |\lines |\of |\code |\into |\the |\correct |\order |\to |\accomplish |\the |\following: The |\messages |"Great |\month" |\and |"Keep |\it |\going" |\are |
printed |\for |\month |\sales |\of |\over |\10000. Not |\all |\lines |\of |\code |\will |\be |\used. |- |\CORRECT |\ANSWERS |
✔✔if |\month_sales>10000: print("Great |\month") print("Keep |\it |\going") Choose |\the |\correct |\lines |\of |\code |\to |\satisfy |\the |\needs |\of |
the |\following |\function: Students |\with |\scores |\of |\ 90 |\or |\higher |\get |\an |\A. Students |\with |\scores |\from |\ 80 |\to |\ 89 |\get |\a |\B. Students |\with |\scores |\from |\ 70 |\to |\ 79 |\get |\a |\C. Everyone |\else |\gets |\an |\F. |- |\CORRECT |\ANSWERS |\✔✔score |\
== |\90: score |>= |\80: score |>= |\70:
day |\in |\week |\ 1 |\and |\ending |\with |\ 50 |\minutes |\a |\day |\in |\week |\
Choose |\the |\correct |\line |\of |\code |\to |\start |\this |\iteration |\and |
finish |\this |\code |\example. |- |\CORRECT |\ANSWERS |\✔✔for |
week |\in |\range(1,6) A |\developer |\needs |\to |\add, |\to |\an |\existing |\app, |\code |\that |
will |\print |\a |\message |\a |\set |\number |\of |\times. |\However, |\the |
developer |\does |\not |\yet |\know |\the |\message |\but |\the |
variables |\used |\in |\the |\loop |\for |\a |\message |\are |\used |
elsewhere |\in |\the |\app. |\Which |\keyword, |\when |\added |\to |\the |
end |\of |\the |\code, |\will |\serve |\as |\a |\placeholder |\for |\future |
text? Here |\is |\the |\code |\example: for |\x |\in |\range(1,5): |- |\CORRECT |\ANSWERS |\✔✔Pass Complete |\the |\code |\examples |\to |\build |\a |\function |\that |\does |\the |\following: Its |\name |\is |\calcSubtotal The |\function |\takes |\an |\amount |\and |\a |\sales |\tax |\rate |\and |
calculates |\a |\subtotal The |\new |\subtotal |\is |\returned |- |\CORRECT |\ANSWERS |\✔✔def |\calcSubtotal (amount, |\salesTaxRate): return |\subtotal
Take |\a |\look |\at |\the |\following |\code |\example, |\used |\to |
calculate |\a |\subtotal |\for |\an |\order: def |\calcTotal(taxable, |\amount, |\sales |\tax, |\shipping): if |\taxable=="Yes": subtotal=amount+(1salesTax)+shipping elif |\shipping==0: pass else: |
subtotal=amount+shipping return |\subtotal order1=calcTotal("No", |\500, |.07, |\0) print("Your |\order |\total |\is |", |\order1) |- |\CORRECT |\ANSWERS |
✔✔null Take |\a |\look |\at |\the |\following |\function: def |\subtotal(order_amt, |\sales_tax): subtotal=float(order_amt)(1+float(sales_tax)) return |\subtotal Which |\code |\example |\properly |\calls |\the |\function |\and |
returns |\a |\calculation, |\stored |\in |\a |\variable |\called |
order_total?? |- |\CORRECT |\ANSWERS |\✔✔order_toal |= |
subtotal(500,.07)
main |\module, |\and |\the |\actual |\unit |\test |\to |\run |\to |\see |\if |\two |
values |\are |\equal |\to |\each |\other. |
Using |\the |\dropdown |\arrows, |\fill |\in |\the |\code |\needed |\to |
finish |\building |\the |\unit |\test. |- |\CORRECT |\ANSWERS |
✔✔TestCase assertEqual name_ In |\the |\following |\code |\example, |\add |\the |\necessary |\code |\to |
tell |\python |\to |\read |\and |\print |\the |\text |\file |\being |\opened, |\if |
the |\file |\already |\exists. |\If |\the |\file |\does |\not |\exist, |\print |\a |
message |\indicating |\as |\such. |- |\CORRECT |\ANSWERS |
✔✔exists workFile.read() A |\junior |\Python |\programmer |\wants |\to |\have |\a |\user |\input |\a |
location |\and |\then |\have |\the |\location |\print |\on |\the |\screen. |\In |\addition, |\the |\developer |\wants |\to |\tell |\the |\user |\to |\enter |
North, |\South, |\East, |\or |\West |\for |\a |\location. |\Using |\drag |\and |
drop, |\drag |\over |\the |\lines |\of |\code |\necessary |\to |\accomplish |\this. |\Not |\every |\line |\of |\code |\will |\be |\used. |- |\CORRECT |
ANSWERS |\✔✔location=["North","South","West","East"] response=input["North,South,West, |\or |\East |\for |\a |
location."] while |\response |\not |\in |\location: print("Try |\again.")
response=input["North,South,West, |\or |\East |\for |\a |
location."] Using |\the |\dropdown |\arrow, |\add |\the |\symbol |\needed |\to |\get |
the |\number |\of |\items |\to |\print |\instead |\of |{items}. The |\following |\code |\example, |\as |\is, |\prints |"You |\have |
{items} |\items |\in |\stock" |\instead |\of |\the |\number |\of |\items |\in |
stock. |- |\CORRECT |\ANSWERS |\✔✔f Evaluate |\the |\following |\code |\that |\writes |\a |\message |\to |\an |
existing |\log |\file |\at |\the |\start |\of |\each |\day: with |\open('log.txt','w') |\as |\file: file.write('Daily |\Log') file.close() |- |\CORRECT |\ANSWERS |\✔✔The |\close |\function |\is |
not |\needed. The |\log |\file |\is |\overwritten |\each |\time |\it |\is |\opened. When |\using |\the |\sys.argv[0] |\command |\as |\part |\of |\running |\a |\Python |\app |\in |\a |\command |\prompt, |\what |\does |\the |\ 0 |
represent |\in |\sys.argv? |- |\CORRECT |\ANSWERS |\✔✔The |\file |
name Take |\a |\look |\at |\the |\following |\code |\example: carLoan=
Take |\a |\look |\at |\the |\code |\example |\below. |\In |\the |\missing |
code |\area, |\indicate |\the |\keyword |\or |\method |\necessary |\to |
throw |\an |\exception |\that |\the |\calling |\code |\can |\catch. |\Also, |
indicate |\the |\missing |\keyword |\to |\show |\a |\block |\of |\code |\no |
matter |\the |\outcome |\of |\the |\try |\portion |\of |\the |\error |
handling |\process. |- |\CORRECT |\ANSWERS |\✔✔raise finally An |\inventory |\manager |\needs |\to |\take |\data |\from |
calculations, |\an |\average |\inventory |\number |\in |\this |\case |
and |\have |\three |\possible |\outcomes: |\the |\nearest |\whole |
number |\up, |\represented |\by |\the |\upper_bound |\variable, |\the |\nearest |\whole |\number |\down, |\represented |\by |\the |
lower_bound |\variable, |\and |\the |\integer |\of |\the |\whole |
number, |\represented |\by |\the |\bound |\variable. |\Using |\the |
dropdown |\lists, |\complete |\the |\code |\snippet |\needed |\to |
fulfill |\the |\inventory |\manager's |\needs. |- |\CORRECT |
ANSWERS |\✔✔import |\math math.ceil math.floor math.trunc A |\game |\developer |\is |\testing |\some |\random |\number |
generators. |\The |\results |\should |\be |\as |\follows:
result1 |\should |\have |\a |\random |\country |\from |\a |\list |\of |
countries result2 |\should |\display |\the |\list |\in |\a |\random |\order result3 |\should |\display |\two |\random |\countries |\from |\a |\list |\of |
countries Using |\the |\dropdown |\arrows, |\fill |\in |\the |\code |\needed |\to |
generate |\the |\proper |\random |\numbers |\for |\each |\variable. |- |
CORRECT |\ANSWERS |\✔✔import |\random choice(countries) shuffle(countries) sample(countries,2) A |\new |\Python |\developer |\is |\a |\learning |\build-in |\modules |
and |\the |\methods |\used |\in |\those |\modules. |\Specifically, |\the |
developer |\needs |\to |\know |\the |\modules |\used |\to |\open |\text |
files, |\find |\the |\mean |\from |\a |\series |\of |\test |\scores, |\make |
directories |\within |\Python, |\and |\exit |\a |\gaming |\app |\when |\the |\game |\is |\over. |\Using |\drag |\and |\drop, |\match |\each |\method |
with |\the |\built-in |\module |\used. |- |\CORRECT |\ANSWERS |\✔✔io math os sys Using |\the |\snippets |\of |\code |\below, |\use |\the |\drag-and-drop |
method |\to |\build |\code |\that |\will |\do |\the |\the |\following:
cities=['Anchorage','Juneau','Fairbanks','Ketchikan','Sitka', 'Wasilla'] for |\city |\in |\range(cities): print(f'{city} |\is |\a |\famous |\Alaskan |\city.') if |\city |== |'Ketchikan': break |- |\CORRECT |\ANSWERS |\✔✔ 4 Analyze |\the |\following |\code: a= b= c= a*=b b=c a//=b For |\each |\statement |\regarding |\the |\values |\of |\these |
variables, |\indicate |\Yes |\if |\the |\statement |\is |\false. c== b== a==1 |- |\CORRECT |\ANSWERS |\✔✔Yes Yes No
Evaluate |\the |\following |\code: |
a= b= c= Using |\these |\variables, |\determine |\if |\each |\calculation |\is |
true. |\Indicate |\a |\Yes |\if |\it |\is |\true |\and |\a |\No |\if |\it |\is |\not. a>b |\and |\b>c a>c |\and |\not |(b+c>a) a+bc==85 |\or |\a-bc==15 |- |\CORRECT |\ANSWERS |\✔✔Yes |
No No