Compsci 101, Fall 2012, Lab 2
By entering your name/net-id below you indicate you are present for Lab 2
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: _____________
-
String Slicing and Dicing
Provide your answers to 3-7, creating each word by slicing:
-
-
-
-
-
-
-
-
Create your own slicing/word puzzle: what's the word and what's the
answer?
Vocabulary
- What do you think the name of the string method is that returns the
lower case version of a string?
- The function
max returns the maximal value of a string
as well as a list. What is max("science") and why?
- What is the value of
reversed(sorted([5,4,1,2,8])) and
why?
- What is the value of
sorted(lst).index(min(lst)) for
any list lst? Why? What's the value if
min is replaced by max?
- Why is the value of
str.endswith(str[-3:]) True?
- When is the value of
st.upper().endswith(st) True?
(Provide a specific example of when it's true and try to generalize)
- The
in operator determines if its left operand occurs
in its right operand and returns a boolean value. This means
'a' in 'stranger' evaluates to True. What
is the value of 5 in [1,2,3,4]?
- Explain when the value of
st[0:2] in st is False?
(Provide a specific example of when it's true and try to generalize)
- Explain when the value of
st[0:2]*2 in st is True?
(Provide a specific example of when it's true and try to generalize)
- When is the value of
lst.count(lst[0]) the same
as the value of len(lst) for a list lst?
(Provide a specific example of when it's true and try to generalize)
APT Acronym
Write a brief, English description of how to solve the APT.
- Complete the code statement below.
words =
- Write the for-loop here:
- Write loop to create the acronym:
acro = ""
return acro