1. indicate whether each method works for strings or lists.\n1..lower()\na. string\nb. list\n2..endswith()\n3…

1. indicate whether each method works for strings or lists.\n1..lower()\na. string\nb. list\n2..endswith()\n3..append()\n4..upper()\n5..reverse()\n6..startswith()\n7..split()\n2. rank yourself on a scale of 1 - 4 on how well you completed the lab project for lesson 2.\n1 - i looked at it, but didn’t even try it.\n2 - i spent a few minutes (about 5) trying to figure it out but gave up.\n3 - it mostly works, but there are a couple bugs i haven’t been able to resolve.\n4 - it works perfectly without any problems.\n3. the function range(4) returns the sequence \n1, 2, 3\n0, 1, 2, 3\n0, 1, 2, 3, 4\n1, 2, 3, 4
Answer
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 therange(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.
Answer:
- 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