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 3 Question 32 Discussion

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

Tien
14 days ago
This question is a piece of cake! The code clearly shows three hashes, so D is the way to go. Though, I did hear that the test developers have a twisted sense of humor, so who knows?
upvoted 0 times
...
Cassandra
15 days ago
Wait, wait, wait... What if the code actually outputs one hash, and the three hashes we see are just a mirage? I'm going with A, just to be safe.
upvoted 0 times
...
Cherry
24 days ago
Hold up, are we sure this isn't a trick question? I bet the answer is zero, just to mess with us. But I'm sticking with D for now.
upvoted 0 times
...
Danica
27 days ago
Hmm, I'm not sure. Let me count the hashes again... Yep, it's definitely three. D it is!
upvoted 0 times
Selma
1 days ago
User 2: Yeah, I agree. Let's go with option D.
upvoted 0 times
...
Lavonda
16 days ago
User 1: I think it's three hashes.
upvoted 0 times
...
...
Tiffiny
27 days ago
But the code only has two hashes, so it should output two hashes to the screen.
upvoted 0 times
...
Thurman
28 days ago
I believe the answer is D) three.
upvoted 0 times
...
Carla
1 months ago
The code clearly outputs three hashes, so I'm going with D. Easy peasy!
upvoted 0 times
Ettie
22 days ago
I agree with you, it's definitely three hashes. D is the correct answer.
upvoted 0 times
...
Cassi
23 days ago
I think it's five hashes, so I'm going with C.
upvoted 0 times
...
...
Tiffiny
1 months ago
I think the answer is C) five.
upvoted 0 times
...

Save Cancel