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 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:

Corazon
1 day ago
Definitely B, it throws an exception!
upvoted 0 times
...
Tracie
7 days ago
I think the output is D.
upvoted 0 times
...
Vanna
14 days 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
19 days ago
I feel like the answer could be False, but I can't recall the exact logic behind it.
upvoted 0 times
...
Felicidad
25 days ago
I remember something about exceptions in similar questions, so maybe it raises an unhandled exception instead?
upvoted 0 times
...
Geoffrey
1 month 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
1 month 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
1 month 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
1 month 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
1 month 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
1 month 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
1 month 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
1 month 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
1 month 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
1 month 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
6 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
6 months ago
Hold up, I'm pretty sure it's just a single star. D all the way!
upvoted 0 times
Melvin
5 months ago
No way, it's definitely just one star, D) *
upvoted 0 times
...
Melvin
5 months ago
I think it's actually three stars, so B) * * *
upvoted 0 times
...
...
Marla
7 months ago
I'm with Pete on this one. The pattern is obvious. * * *
upvoted 0 times
Jerry
5 months ago
The expected output is B) * * *
upvoted 0 times
...
Zona
5 months ago
Yes, it's definitely B) * * *
upvoted 0 times
...
Luisa
6 months ago
I agree, the pattern is clear. It should be B) * * *
upvoted 0 times
...
Catherin
6 months ago
I think the answer is B) * * *
upvoted 0 times
...
...
Antonio
7 months ago
But the code only prints one asterisk, so the answer should be D)
upvoted 0 times
...
Pearline
7 months ago
I disagree, I believe the answer is D) *
upvoted 0 times
...
Pete
7 months ago
The output is clearly three stars, so it's gotta be B.
upvoted 0 times
Ernest
5 months ago
Yes, the correct answer is B) * * *
upvoted 0 times
...
Jessenia
5 months ago
The code definitely produces three stars as output.
upvoted 0 times
...
Shantell
6 months ago
I agree, it looks like the code will output three stars.
upvoted 0 times
...
Bo
6 months ago
I think the answer is B) * * *
upvoted 0 times
...
...
Corazon
7 months ago
Hmm, looks like a tricky one. Gotta think through this carefully.
upvoted 0 times
...
Antonio
7 months ago
I think the answer is C) * *
upvoted 0 times
...

Save Cancel