Compsci 06/101, Spring 2012, Lab 5
By entering your name/net-id below you indicate you are present for Lab 5
to answer these questions and that you were part of
the process that resulted in answers being turned in.
Name: ______________ Net id: _____________ || Name: ______________ Net id: _____________
Name: ______________ Net id: _____________ || Name: ______________ Net id: _____________
Test Practice
- What is the value of
x after line 5 executes?
- What is the value of
amount after line 5 executes?
- What is the value of
y after line 6 executes?
- What value is stored in
result by the call shown?
- Rewrite lines 2-5 so that
x is assigned a value via
a list comprehension on one line:
x =
- First write one or two sentences describing the approach you'll
take in writing the function: what functions will you call, what
will you loop over, what will you return?
- Write the function
def getAges(data):
SandwichBar
- Why loop via an index in the SandwichBar APT?
- Why will you need to call split in the loop above, e.g., on
order[index]? (in words)
- First, what's the purpose (in words) of the boolean variable
ok shown above?
- After the loop above executes, what should be returned if
the value of
ok is True?
- The APT specifies that -1 is returned if no sandwhich can be
made, when will that happen and where does the return statement
go?
Poker
What odds did you calculate for each of the following poker hands?
- Pair (over how many dealt hands)?
- Two Pair (code and probability)
- Three of a Kind (code and probability)
- Full House (code and probability)
- Challenge Flush (code and probability)