Name_________________ net-id _______ Name_________________ net-id _______ Name_________________ net-id _______ Name_________________ net-id _______
st when the
code below executes? Explain (to yourself or the class, you don't have
to write it down) your answer.
word = "creation"
st = ""
for i in range(0,len(word)):
if i % 2 == 0:
st = st + word[i]
print st # value here?
"ceto"
"rain"
"ratio"
words = ["self", "contained", "underwater", "breathing", "apparatus"]
abb = ""
for w in words:
abb = abb + w[1]
print abb
"scuba"
"eonrp"
"secounbrap"
The Yahtzee/ScoreIt APT
was suggested for the Yahtzee/Scoreit APT in which you determine the
maximal score in the "above the line" section of a Yahtzee game. The
idea is expressed in the code below to process the list
toss, where toss has five-values 1-6 representing die
rolls. For purposes of this exposition assume
toss=[3,2,5,3,5] -- the first step is to count the number
of occurrences of each possible die-roll.
counts?
counts = [toss.count(i) for i in toss]
counts = [toss.count(i) for i in range(1,7)]
counts = [toss[i] for i in range(1,7)]
toss as shown:
return max([i*toss.count(i) for i in range(1,7)])
return max([toss[i]*toss.count(i) for i in range(1,7)])
return max([i*toss[i] for i in range(1,7)])
return max([i*toss.count(i) for i in toss])