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

Unlimited Access

Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.

Exam PCAP topic 1 question 90 discussion

Actual exam question from Python Institute's PCAP
Question #: 90
Topic #: 1
[All PCAP Questions]

What is the expected behavior of the following code?

  • A. it raises an exception
  • B. it outputs True
  • C. it outputs False
  • D. it outputs nothing
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
Bonesaw
1 month, 3 weeks ago
Selected Answer: B
I agree with roncr, the ; should be : instead. Also isaplpha() should be isalpha(). Once those are corrected it returns True
upvoted 1 times
...
roncr
4 months, 3 weeks ago
there is a typo, is ; instead of : so its B "true"
upvoted 3 times
...
mplopez
7 months ago
Selected Answer: A
Hi, check the code twice before give your answers. If you read correctly the code if you execute it you will see that as it's wrote the response is an exception, so the answer is A. Normally, you need to answer as you have in the questionnaire
upvoted 1 times
...
aferiver
11 months, 3 weeks ago
Selected Answer: C
C. False typo in alpha() The first line of code creates a list with one element, which is ‘alpha;beta;gamma’. However, the delimiter used in the split method is ‘:’ instead of ‘;’, so the list will only contain one element. The second line of code joins all elements in the list into a single string, which will be ‘alpha;beta;gamma’. The third line of code checks if the string ‘alpha;beta;gamma’ contains only alphabetic characters, which is False because it contains ‘;’.
upvoted 4 times
...
carpmatias
1 year, 10 months ago
Selected Answer: C
Only if there is a typo in 'isaplpha()' and it means actually 'isalpha()' the it's C
upvoted 3 times
...
macxsz
1 year, 10 months ago
Selected Answer: C
C. it outputs False
upvoted 1 times
...
sadako11
2 years, 1 month ago
Another question with a possible typo. Is it supposed to be 'isalpha()' or 'isaplpha()'? Using 'isalpha()' gives a False and using 'isaplpha()' gives an error
upvoted 3 times
...
lukaki
2 years, 4 months ago
Answer C; #Example_1 the_list='alpha;beta;gamma'.split(":") print(the_list) the_string=''.join(the_list) print(the_string) print(the_string.isalpha()) # Output: # ['alpha;beta;gamma'] # alpha;beta;gamma # False #Example_2 the_list='alpha:beta:gamma'.split(":") print(the_list) the_string=''.join(the_list) print(the_string) print(the_string.isalpha()) # Output: # ['alpha', 'beta', 'gamma'] # alphabetagamma # True
upvoted 3 times
...
Efren
2 years, 4 months ago
C- False: the_list='alpha;beta;gamma'.split(":") >>> the_list ['alpha;beta;gamma'] >>> the_string=''.join(the_list) >>> the_string 'alpha;beta;gamma' >>> print(the_string.isalpha()) False
upvoted 2 times
...
mazimir
2 years, 5 months ago
It outputs: False. Because of .split(":") output of the_list is list with one element ["alpha;beta;gamma"]
upvoted 2 times
Hrishi8888
2 years, 5 months ago
The spelling if isalpha() is also wrong in code
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 ...