Deal of The Day! 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 1 Question 17 Discussion

Actual exam question for Python Institute's PCEP-30-02 exam
Question #: 17
Topic #: 1
[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:

Gertude
3 months ago
Wow, this question is really making my head spin. I'm just going to close my eyes and randomly pick an answer. Maybe I'll get lucky and it'll be the right one. Or maybe I'll end up with a free trip to the moon. Either way, it's worth a shot!
upvoted 0 times
Lauran
2 months ago
User 3: I'll go with D) three.
upvoted 0 times
...
Tijuana
2 months ago
User 2: I'm going with A) one.
upvoted 0 times
...
Merlyn
2 months ago
User 1: I think the answer is B) zero (the code outputs nothing).
upvoted 0 times
...
...
Jean
3 months ago
Aha! I know this one. The code is clearly outputting three hashes, so the answer is D) three. Easy peasy!
upvoted 0 times
Verdell
2 months ago
No, I'm pretty sure it's three hashes, so the answer is D) three.
upvoted 0 times
...
Whitley
2 months ago
I think it's five hashes, so the answer is C) five.
upvoted 0 times
...
Howard
2 months ago
No, it's actually D) three. The code outputs three hashes.
upvoted 0 times
...
Wai
2 months ago
No, I'm pretty sure it's three hashes, so the answer is D) three.
upvoted 0 times
...
Lonny
2 months ago
I think it's actually outputting five hashes, so the answer is C) five.
upvoted 0 times
...
Glendora
2 months ago
I think the answer is A) one.
upvoted 0 times
...
...
Veda
3 months ago
Hmm, this looks like a tricky one. I'm going to say B) zero, because the code doesn't seem to have any output statements. Although, maybe it's printing the hashes in invisible ink or something. Who knows?
upvoted 0 times
...
Davida
3 months ago
The code looks like it's printing some hashes, but I'm not sure how many. I'll go with C) five just to be safe.
upvoted 0 times
Rebecka
2 months ago
I think it's D) three.
upvoted 0 times
...
Dominic
2 months ago
I'm going with C) five.
upvoted 0 times
...
Allene
2 months ago
I believe it's B) zero (the code outputs nothing).
upvoted 0 times
...
Evangelina
3 months ago
I think the answer is A) one.
upvoted 0 times
...
...

Save Cancel