QUESTION IMAGE
Question
- indicate whether each method works for strings or lists.
1..lower()
a. string
b. list
2..endswith()
3..append()
4..upper()
5..reverse()
6..startswith()
7..split()
- rank yourself on a scale of 1 - 4 on how well you completed the lab project for lesson 2.
1 - i looked at it, but didn’t even try it.
2 - i spent a few minutes (about 5) trying to figure it out but gave up.
3 - it mostly works, but there are a couple bugs i haven’t been able to resolve.
4 - it works perfectly without any problems.
- the function range(4) returns the sequence
1, 2, 3
0, 1, 2, 3
0, 1, 2, 3, 4
1, 2, 3, 4
Brief Explanations
- The
.lower()method is used to convert all characters in a string to lowercase. It only works for strings. - The
.endswith()method checks if a string ends with a specified suffix. It is for strings. - The
.append()method is used to add an element to the end of a list. It is for lists. - The
.upper()method converts all characters in a string to uppercase. It is for strings. - In Python, lists have a built - in
.reverse()method to reverse the order of elements in the list. Some string - like sequences also have ways to reverse, but the native.reverse()is for lists. - The
.startswith()method checks if a string starts with a specified prefix. It is for strings. - The
.split()method splits a string into a list of substrings based on a delimiter. It is for strings.
For the range(4) function in Python, it generates a sequence of numbers starting from 0 and going up to (but not including) 4, so it returns 0, 1, 2, 3.
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
1.
- 1..lower(): a. String
- 2..endswith(): a. String
- 3..append(): b. List
- 4..upper(): a. String
- 5..reverse(): b. List
- 6..startswith(): a. String
- 7..split(): a. String
- (This is a self - assessment question, no fixed answer)
- 0, 1, 2, 3