New Year Sale 2026! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

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

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

0/2000 characters
Aron
4 days ago
B is the correct answer. The code doesn't output anything to the screen.
upvoted 0 times
...
Avery
9 days ago
I'm pretty sure the answer is C. The code looks like it should output five hashes.
upvoted 0 times
...
Lynelle
14 days ago
The code clearly outputs three hashes, so the answer is D.
upvoted 0 times
...
Stephanie
19 days ago
I’m leaning towards one hash being printed, but I can't recall the exact details of the code.
upvoted 0 times
...
Natalya
24 days ago
I’m confused about the logic in the code. It could be five, but I really need to double-check the loop structure.
upvoted 0 times
...
Lavelle
30 days ago
I remember a similar question where the output was based on a condition. I feel like this one might output three hashes.
upvoted 0 times
...
Izetta
1 month ago
I think the code might output zero hashes, but I'm not entirely sure. It looks like it could be a loop that doesn't run.
upvoted 0 times
...
Luis
1 month ago
I'll start by breaking down the code and analyzing each part. That should help me arrive at the right answer.
upvoted 0 times
...
Elli
2 months ago
I'm a bit confused by the nested loops. I'll need to make sure I understand how they're interacting to determine the output.
upvoted 0 times
...
Aja
2 months ago
Ah, I've seen problems like this before. I'm pretty confident I can solve this one.
upvoted 0 times
...
Arletta
2 months ago
Okay, let me think this through step-by-step. I think I can work this out, but I'll need to be methodical.
upvoted 0 times
...
Georgeanna
2 months ago
Hmm, this looks like a tricky one. I'll need to carefully trace the code to figure out the output.
upvoted 0 times
...

Save Cancel