Computer Science, asked by jagdishsingh01k, 7 months ago

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 bhavanij0705
7

your answer is b.(pen)

hope it helps you

Answered by rahul123437
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