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 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
Edgar
16 days ago
I'm not sure, but I think one is possible. It might print once.
upvoted 0 times
...
Georgene
21 days ago
I'm leaning towards five. I see multiple print statements.
upvoted 0 times
...
Carli
27 days ago
I feel like it should be three. The loops seem to add up.
upvoted 0 times
...
Raymon
1 month ago
I think it outputs zero. The code looks empty.
upvoted 0 times
...
Hector
1 month ago
Three seems right based on the logic.
upvoted 0 times
...
Glennis
1 month ago
I don't see how it could be one.
upvoted 0 times
...
Alberta
2 months ago
Wait, are you sure? I thought it was five.
upvoted 0 times
...
Lorean
2 months ago
Definitely zero, the code is empty!
upvoted 0 times
...
Mitsue
2 months ago
I think it outputs three hashes.
upvoted 0 times
...
Bev
2 months ago
Wait, is this a trick question? I'm going to go with the classic "none of the above" and choose B.
upvoted 0 times
...
Jettie
2 months ago
Haha, this question is a real head-scratcher. I'm going to go with D and hope for the best!
upvoted 0 times
...
Aron
3 months ago
B is the correct answer. The code doesn't output anything to the screen.
upvoted 0 times
...
Avery
3 months ago
I'm pretty sure the answer is C. The code looks like it should output five hashes.
upvoted 0 times
...
Lynelle
3 months ago
The code clearly outputs three hashes, so the answer is D.
upvoted 0 times
...
Stephanie
3 months ago
I’m leaning towards one hash being printed, but I can't recall the exact details of the code.
upvoted 0 times
...
Natalya
4 months 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
4 months 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
4 months 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
4 months 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
4 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
5 months ago
Ah, I've seen problems like this before. I'm pretty confident I can solve this one.
upvoted 0 times
...
Arletta
5 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
5 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
Vi
11 days ago
I think it outputs three hashes.
upvoted 0 times
...
...

Save Cancel