Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
6Activity
0 of .
Results for:
No results containing your search query
P. 1
Shootout

Shootout

Ratings: (0)|Views: 8,275 |Likes:
Published by Mike Zamansky

More info:

Published by: Mike Zamansky on Mar 01, 2012
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

07/31/2014

pdf

text

original

 
1
de
stringTimes (s ,n ):
””s
>
a string ,
>
an integersreturns a string that is made of n copies of sex : stringTimes ( hi ’ , 4)
>
hihihihi ””
2
de
countFives ( l ):
””returns the number of times the number 5 appears in l i s t ex : countFives ([5 , 3, 2, 4, 2, 5, 2, 4, 5, 6, 7])
>
””
3
de
listSum ( l ):
””calculates the sum of a l l the ints in l i s t l (assume a l l elements are ints )ex : listSum ([5 ,2 ,3])
>
10 ””
4
de
numTimes(word , sentence ):
””word 
>
a string sentence
>
a string returns the number of times word appears in sentence .hint : turn sentence into a l i s t of words using s p l i ex : numtimes( the , it is the time of the season ’)
>
numtimes( happy , this sentence does not have the word in question ’)
>
””
5
de
countOdds( l ):
””
>
a l i s t of numbersreturns : the number of odd items in the l i s You can determine i f a number is odd or even using the mod operator 
\
%.For example 5 
\
%2 evaluates to 1 and 6 
\
%2 evaluates to 0 ””
1

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->