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 4 Question 30 Discussion

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

What is the expected output of the following code?

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
Reta
3 months ago
I agree with Edgar, 3 makes sense!
upvoted 0 times
...
Kristeen
3 months ago
Wait, is it really 1? That seems off.
upvoted 0 times
...
Jeannetta
3 months ago
I’m leaning towards 4, seems right.
upvoted 0 times
...
Lisandra
4 months ago
Definitely not A, that’s for sure!
upvoted 0 times
...
Edgar
4 months ago
I think the output is 3.
upvoted 0 times
...
Ashanti
4 months ago
I thought it could be 4, but now I'm second-guessing myself after reviewing the options.
upvoted 0 times
...
Stephaine
4 months ago
I'm leaning towards 1 as the output, but I can't recall the exact logic behind it.
upvoted 0 times
...
Micah
4 months ago
I feel like I've seen a similar question before, and the output was 3. Maybe that's the right answer?
upvoted 0 times
...
My
5 months ago
I think the code might output nothing, but I'm not entirely sure. I remember something about print statements.
upvoted 0 times
...
Reta
5 months ago
Hmm, I'm not sure about this. I'll need to review the concepts covered in class to help me solve this problem.
upvoted 0 times
...
Sheron
5 months ago
I'm feeling pretty confident about this one. The code seems straightforward, and I think I know the expected output.
upvoted 0 times
...
Toshia
5 months ago
I'm a bit confused by the code, but I think I can work it out. I'll start by looking at the loop and the conditions inside it.
upvoted 0 times
...
Xochitl
5 months ago
Okay, let me think this through. The code is using a loop and some conditional statements, so I'll need to pay close attention to the logic.
upvoted 0 times
...
Deane
5 months ago
Hmm, this looks like a tricky one. I'll need to carefully step through the code to figure out the expected output.
upvoted 0 times
...
Rosann
10 months ago
If this was a coding challenge, I'd just run the code and see what happens. But since it's a test, I'll have to rely on my powers of deduction. Let's see, maybe it's printing stars in a triangle? Nah, that's too easy. I'm going with B) * * *. Hopefully, I'll get a star for that answer!
upvoted 0 times
Wilda
9 months ago
I agree with you, I also think it's B) * * *
upvoted 0 times
...
Becky
9 months ago
I believe the answer is C) * *
upvoted 0 times
...
Elouise
9 months ago
I think it's D) *
upvoted 0 times
...
...
Alaine
10 months ago
I'm feeling lucky today, so I'm going to go with C) * *. It's the middle ground, and who knows, maybe the code is doing something unexpected.
upvoted 0 times
Georgeanna
9 months ago
User 3: I'm feeling lucky today, so I'm going to go with C) * *.
upvoted 0 times
...
Arleen
9 months ago
User 2: I'm going with D) *.
upvoted 0 times
...
Gertude
10 months ago
User 1: I think the output will be B) * * *.
upvoted 0 times
...
...
Ines
10 months ago
This is clearly a trick question. The code looks simple, but I bet it doesn't produce any output at all. I'm going with A) The code produces no output.
upvoted 0 times
Justine
8 months ago
Final answer: A) The code produces no output.
upvoted 0 times
...
Alisha
9 months ago
Let's go with option A) The code produces no output.
upvoted 0 times
...
Georgeanna
10 months ago
I agree, I also think the code produces no output.
upvoted 0 times
...
Brittni
10 months ago
I think you're right, it does seem like a trick question.
upvoted 0 times
...
...
Sherrell
11 months ago
Hmm, the code seems pretty straightforward. I bet it just prints a single star, so I'm going with D) *.
upvoted 0 times
Ling
9 months ago
I agree with Azalee, I also think it will print three stars. B) * * *.
upvoted 0 times
...
Azalee
10 months ago
I think it will print three stars, so I choose B) * * *.
upvoted 0 times
...
...
Bette
11 months ago
The code looks like it's printing stars, so I'm guessing the output is going to be some kind of star pattern. I'll go with B) * * *.
upvoted 0 times
Sharee
10 months ago
I agree with you, I also think it will be a star pattern, I'll go with B) * * *
upvoted 0 times
...
Selma
10 months ago
I believe the code will print a single star, so my answer is D) *
upvoted 0 times
...
Afton
10 months ago
I think the output will be a diagonal line of stars, so I choose C) * *
upvoted 0 times
...
...
Lashawn
11 months ago
Why do you think that?
upvoted 0 times
...
Makeda
11 months ago
I disagree, I believe the output is D) *
upvoted 0 times
...
Lashawn
11 months ago
I think the expected output is C) * *
upvoted 0 times
...

Save Cancel