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 2 Question 21 Discussion

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

Jerilyn
11 days ago
Zero? Really? That code is definitely going to output something. I'm sticking with D - three hashes.
upvoted 0 times
...
Judy
12 days ago
Haha, this question is a hash-off! I bet it's option C - five hashes. The more the merrier, right?
upvoted 0 times
...
Shaquana
29 days ago
You're right, I change my answer to A) one.
upvoted 0 times
...
Brianne
1 months ago
But the code only has two hashes, so it can't be five.
upvoted 0 times
...
Eliz
1 months ago
Hmm, the code is a bit tricky. I'm gonna go with option D. Three hashes seems right to me.
upvoted 0 times
Maybelle
13 days ago
I'm going with option D, three hashes.
upvoted 0 times
...
Nakita
17 days ago
I believe it outputs zero, nothing on the screen.
upvoted 0 times
...
Merilyn
26 days ago
I think it outputs one hash.
upvoted 0 times
...
...
Shaquana
1 months ago
I believe it's D) three.
upvoted 0 times
...
Alton
1 months ago
The output looks like it will be 3 hashes. I'm pretty sure that's the correct answer.
upvoted 0 times
Sheridan
24 days ago
I agree, it looks like the correct answer is A) one.
upvoted 0 times
...
Kathrine
25 days ago
I think it will output one hash.
upvoted 0 times
...
...
Brianne
1 months ago
I think the answer is C) five.
upvoted 0 times
...

Save Cancel