Cyber Monday 2024! 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
4 months ago
Zero? Really? That code is definitely going to output something. I'm sticking with D - three hashes.
upvoted 0 times
...
Judy
4 months ago
Haha, this question is a hash-off! I bet it's option C - five hashes. The more the merrier, right?
upvoted 0 times
Tawna
3 months ago
I agree with you, I also think it's option A.
upvoted 0 times
...
Brandon
3 months ago
I think it's option A - one hash.
upvoted 0 times
...
...
Shaquana
4 months ago
You're right, I change my answer to A) one.
upvoted 0 times
...
Brianne
5 months ago
But the code only has two hashes, so it can't be five.
upvoted 0 times
...
Eliz
5 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
4 months ago
I'm going with option D, three hashes.
upvoted 0 times
...
Nakita
4 months ago
I believe it outputs zero, nothing on the screen.
upvoted 0 times
...
Merilyn
4 months ago
I think it outputs one hash.
upvoted 0 times
...
...
Shaquana
5 months ago
I believe it's D) three.
upvoted 0 times
...
Alton
5 months ago
The output looks like it will be 3 hashes. I'm pretty sure that's the correct answer.
upvoted 0 times
Sheridan
4 months ago
I agree, it looks like the correct answer is A) one.
upvoted 0 times
...
Kathrine
4 months ago
I think it will output one hash.
upvoted 0 times
...
...
Brianne
5 months ago
I think the answer is C) five.
upvoted 0 times
...

Save Cancel
az-700  pass4success  az-104  200-301  200-201  cissp  350-401  350-201  350-501  350-601  350-801  350-901  az-720  az-305  pl-300  

Warning: Cannot modify header information - headers already sent by (output started at /pass.php:70) in /pass.php on line 77