Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam PCEP-30-02 All Questions

View all questions & answers for the PCEP-30-02 exam

Exam PCEP-30-02 topic 1 question 8 discussion

Actual exam question from Python Institute's PCEP-30-02
Question #: 8
Topic #: 1
[All PCEP-30-02 Questions]

What is the expected output of the following code?
print(list('hello'))

  • A. hello
  • B. [h, e, l, l, o]
  • C. ['h', 'e', 'l', 'l', 'o']
  • D. ['h' 'e' 'l' 'l' 'o']
  • E. None of the above.
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
consultsk
1 month, 3 weeks ago
Selected Answer: C
This code does the following: The string 'hello' is passed to the list() function. list() converts the string into a list, where each character of the string becomes an individual element of the list. The resulting list "['h', 'e', 'l', 'l', 'o']" is then printed. Each character from the string 'hello' becomes a separate string element in the list, preserving the order of the original string. The output shows this list of single-character strings.
upvoted 1 times
...
megan_mai
3 months ago
Selected Answer: C
Tested on Databricks list('Hello') >>> a list containing all the character of the work "Hello" print(list('Hello')) >>> print the list with the right format, this is what i got after running the code: ['h', 'e', 'l', 'l', 'o'] (C)
upvoted 1 times
...
christostz03
3 months ago
c is the correct answer
upvoted 1 times
...
AlexNS653
3 months, 1 week ago
Selected Answer: C
Correct answer is C. Anyone who is guessing the answer is 'E' is incorrect, but an easy mistake to make. You are getting the Traceback TypeError traceback because you have a value assigned to the variable 'list' from one of the previous questions. So, when you type 'list' you aren't calling the function list, you are referencing the variable 'list'. Restart your shell and try the print(list('hello')) statement again and it will return ['h', 'e', 'l', 'l', 'o'] as it should. This is why we are taught to never use a reserved word in Python as a variable name.
upvoted 3 times
...
AlexNS653
3 months, 1 week ago
Anyone who is guessing the answer is 'E' is incorrect, but an easy mistake to make. You are getting the Traceback TypeError traceback because you have a value assigned to the variable 'list' from one of the previous questions. So, when you type 'list' you aren't calling the function list, you are referencing the variable 'list'. Restart your shell and try the print(list('hello')) statement again and it will return ['h', 'e', 'l', 'l', 'o'] as it should. This is why we are taught to never use a reserved word in Python as a variable name.
upvoted 1 times
...
tolliik
4 months, 1 week ago
Who got the error: "TypeError: 'list' object is not callable" clear your terminal session. In the question 1, you probably used a variable list, so there is a conflict between the function "list" and a variable "list". So C is right. Not E
upvoted 1 times
...
froster02
4 months, 1 week ago
C, as it is the list so answer will be format of C option only
upvoted 1 times
...
nieups
4 months, 1 week ago
Selected Answer: C
C is the right answer
upvoted 3 times
...
JoeJin
4 months, 2 weeks ago
Selected Answer: E
TypeError Traceback (most recent call last) Cell In[6], line 1 ----> 1 print(list('hello')) TypeError: 'list' object is not callable ​
upvoted 1 times
...
JoeJin
4 months, 2 weeks ago
E is correct according to jupitor notebook... print(list('hello')) TypeError Traceback (most recent call last) Cell In[6], line 1 ----> 1 print(list('hello')) TypeError: 'list' object is not callable ​
upvoted 1 times
...
BAune
4 months, 3 weeks ago
Selected Answer: C
C is correct, tested in Pycharm.
upvoted 3 times
...
vlad29
5 months ago
Selected Answer: E
The restul is: TypeError: 'list' object is not callable
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...