Predict the output of the following expression:
Str1="pen"
print(list(str1))
a) ['p', 'e', 'n']
b) [pen]
c) [p/e/n]
d) {"pen"}
Answers
Answered by
7
your answer is b.(pen)
hope it helps you
Answered by
0
The output of the following expression is a) ['p', 'e', 'n']
Explanation:
Str1="pen"
print(list(str1))
- The first line means: A string is a sequence of characters. We are assigning a string 'pen' in Str1.
- In the second line of the program, a list is used, a list is a data structure in Python that is a mutable, or changeable, ordered sequence of elements. Each element or value that is inside of a list is called an item. Lists are used to store the data items where each data item is separated by a comma (,).
- The second line means to print the value inside the list structure of Str1 separated by a comma.
- The output of the program we get is a) ['p', 'e', 'n']
Similar questions
English,
3 months ago
Sociology,
3 months ago
Math,
3 months ago
Physics,
7 months ago
Biology,
7 months ago
Social Sciences,
11 months ago
Science,
11 months ago
Accountancy,
11 months ago