For Question 1:
The code snippet is:
dumbledore = "One can never have enough socks."
print(len(dumbledore))
The output of print(len(dumbledore))
calculates the number of characters in the string "One can never have enough socks."
, which is 32 (including spaces and punctuation). The data type of the output is an integer.
So the correct response is: 32; number
For Question 2:
The code snippet is:
studentNames = "Arya,Berric,Cersei,Drogo,Eddard"
studentList = studentNames.split(",")
print(studentList[2])
The split(",")
method splits the string at each comma, resulting in a list: ["Arya", "Berric", "Cersei", "Drogo", "Eddard"]
. The element at index 2 in this list is "Cersei"
.
So the correct response is: Cersei