Cyber Monday 2024! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Python Institute Exam PCEP-30-02 Topic 2 Question 23 Discussion

Actual exam question for Python Institute's PCEP-30-02 exam
Question #: 23
Topic #: 2
[All PCEP-30-02 Questions]

How many hashes (+) does the code output to the screen?

Show Suggested Answer Hide Answer
Suggested Answer: C

The code snippet that you have sent is a loop that checks if a variable ''floor'' is less than or equal to 0 and prints a string accordingly. The code is as follows:

floor = 5 while floor > 0: print(''+'') floor = floor - 1

The code starts with assigning the value 5 to the variable ''floor''. Then, it enters a while loop that repeats as long as the condition ''floor > 0'' is true. Inside the loop, the code prints a ''+'' symbol to the screen, and then subtracts 1 from the value of ''floor''. The loop ends when ''floor'' becomes 0 or negative, and the code exits.

The code outputs five ''+'' symbols to the screen, one for each iteration of the loop. Therefore, the correct answer is C. five.


Contribute your Thoughts:

King
3 months ago
I agree with Lorrie, the code outputs nothing, so B) zero is the correct answer.
upvoted 0 times
...
Lorrie
3 months ago
But the code only has two hashes, so it should be B) zero.
upvoted 0 times
...
Maira
3 months ago
I believe it's D) three.
upvoted 0 times
...
Lorrie
3 months ago
I think the answer is A) one.
upvoted 0 times
...
Judy
3 months ago
I agree with Felix, the answer is C) five because each loop iteration outputs one hash.
upvoted 0 times
...
Felix
3 months ago
But if you count carefully, you'll see that there are actually five hashes in the code.
upvoted 0 times
...
Madelyn
3 months ago
Whoa, this code is really confusing! I'm gonna take a wild guess and say A) one. Who knows, maybe I'll get lucky!
upvoted 0 times
...
Rex
3 months ago
Hold on, I'm counting and I see four hashes, not five. I think the answer is C), but maybe the question is a trick question?
upvoted 0 times
Lorriane
2 months ago
It could be a trick question, but I agree with you that the answer is C) five.
upvoted 0 times
...
Lorriane
3 months ago
I also counted four hashes, so I think the answer is C) five.
upvoted 0 times
...
...
Christiane
3 months ago
Hmm, I'm gonna go with D) three. The number of hashes looks like three to me.
upvoted 0 times
...
Ailene
3 months ago
B) zero seems like the right answer to me. The code doesn't seem to output anything at all.
upvoted 0 times
Lera
2 months ago
I'm pretty sure it's zero. The code doesn't seem to output any hashes.
upvoted 0 times
...
Moon
2 months ago
I think it's one. The code might output a single hash.
upvoted 0 times
...
Elenora
3 months ago
I agree, zero is the correct answer. The code doesn't display anything.
upvoted 0 times
...
...
Rutha
4 months ago
I disagree, I believe the answer is D) three because there are only three hashes being output.
upvoted 0 times
...
Felix
4 months ago
I think the answer is C) five because there are five hashes in the code.
upvoted 0 times
...
Jeannetta
4 months ago
I think the answer is C) five. The code clearly shows 5 hash symbols being output.
upvoted 0 times
Dexter
4 months ago
I believe the correct answer is A) one.
upvoted 0 times
...
Dexter
4 months ago
I think it might be three, not five.
upvoted 0 times
...
Dexter
4 months ago
I agree, the code outputs five hash symbols.
upvoted 0 times
...
...

Save Cancel
az-700  pass4success  az-104  200-301  200-201  cissp  350-401  350-201  350-501  350-601  350-801  350-901  az-720  az-305  pl-300  

Warning: Cannot modify header information - headers already sent by (output started at /pass.php:70) in /pass.php on line 77