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 1 Question 5 Discussion

Actual exam question for Python Institute's PCEP-30-02 exam
Question #: 5
Topic #: 1
[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
Misty
3 months ago
I agree with A, it should just return 1.
upvoted 0 times
...
Jin
3 months ago
Wait, is it really D? That seems off.
upvoted 0 times
...
Fannie
4 months ago
I’m leaning towards C, but not sure.
upvoted 0 times
...
Corazon
4 months ago
Definitely B, it throws an exception!
upvoted 0 times
...
Tracie
4 months ago
I think the output is D.
upvoted 0 times
...
Vanna
4 months ago
I practiced a question like this before, and I think it was about returning a tuple, so D seems likely.
upvoted 0 times
...
Sarah
5 months ago
I feel like the answer could be False, but I can't recall the exact logic behind it.
upvoted 0 times
...
Felicidad
5 months ago
I remember something about exceptions in similar questions, so maybe it raises an unhandled exception instead?
upvoted 0 times
...
Geoffrey
5 months ago
I think the output might be option D, but I'm not entirely sure if the tuple is formatted correctly.
upvoted 0 times
...
Frederic
5 months ago
This is a good test of my knowledge. I'm confident I can work through this step-by-step and arrive at the correct answer.
upvoted 0 times
...
Vanesa
5 months ago
Okay, let me break this down. The code is creating a tuple, so the output should be a tuple. I just need to figure out the exact values that will be in the tuple.
upvoted 0 times
...
Armanda
5 months ago
Ah, I think I've seen something like this before. Let me quickly review the rules around string concatenation and boolean values in this language.
upvoted 0 times
...
Sang
5 months ago
I'm not entirely sure about this one. The output seems a bit ambiguous, so I'll need to double-check my understanding of the language features involved.
upvoted 0 times
...
Kenia
5 months ago
Hmm, this looks like a tricky one. I'll need to carefully read through the code and think through the logic step-by-step.
upvoted 0 times
...
Caitlin
5 months ago
I'm pretty confident about this one. I know CASE and DECODE are both SQL functions, so I'll start by evaluating the statements about them being functions.
upvoted 0 times
...
Sharen
5 months ago
This is a good test of my XSLT knowledge. I'm feeling confident that I can figure out the right answer if I take my time and think it through.
upvoted 0 times
...
Jules
5 months ago
No way, objects should never call other objects. That's a recipe for a tangled mess of dependencies. I'm going with option A.
upvoted 0 times
...
Jame
5 months ago
I'm pretty sure this is asking about the type of query needed for a Prisma Cloud build policy in Terraform. I think the answer is Terraform, since Prisma Cloud integrates with Terraform.
upvoted 0 times
...
Ashleigh
10 months ago
This question is a real star-studded affair, isn't it? I bet the answer is out of this world!
upvoted 0 times
...
Alex
10 months ago
Hold up, I'm pretty sure it's just a single star. D all the way!
upvoted 0 times
Melvin
9 months ago
No way, it's definitely just one star, D) *
upvoted 0 times
...
Melvin
9 months ago
I think it's actually three stars, so B) * * *
upvoted 0 times
...
...
Marla
10 months ago
I'm with Pete on this one. The pattern is obvious. * * *
upvoted 0 times
Jerry
9 months ago
The expected output is B) * * *
upvoted 0 times
...
Zona
9 months ago
Yes, it's definitely B) * * *
upvoted 0 times
...
Luisa
10 months ago
I agree, the pattern is clear. It should be B) * * *
upvoted 0 times
...
Catherin
10 months ago
I think the answer is B) * * *
upvoted 0 times
...
...
Antonio
11 months ago
But the code only prints one asterisk, so the answer should be D)
upvoted 0 times
...
Pearline
11 months ago
I disagree, I believe the answer is D) *
upvoted 0 times
...
Pete
11 months ago
The output is clearly three stars, so it's gotta be B.
upvoted 0 times
Ernest
9 months ago
Yes, the correct answer is B) * * *
upvoted 0 times
...
Jessenia
9 months ago
The code definitely produces three stars as output.
upvoted 0 times
...
Shantell
10 months ago
I agree, it looks like the code will output three stars.
upvoted 0 times
...
Bo
10 months ago
I think the answer is B) * * *
upvoted 0 times
...
...
Corazon
11 months ago
Hmm, looks like a tricky one. Gotta think through this carefully.
upvoted 0 times
...
Antonio
11 months ago
I think the answer is C) * *
upvoted 0 times
...

Save Cancel