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 19 Discussion

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

Desmond
1 months ago
I'm pretty sure the answer is three, but just in case, I'm going to double-check the code. Wouldn't want to mess this up and end up with a 'hash' of a score on the exam.
upvoted 0 times
...
Hollis
1 months ago
Marget
upvoted 0 times
Gail
24 hours ago
B) zero (the code outputs nothing)
upvoted 0 times
...
Gail
5 days ago
A) one
upvoted 0 times
...
Samira
10 days ago
D) three
upvoted 0 times
...
Samira
13 days ago
B) zero (the code outputs nothing)
upvoted 0 times
...
Samira
18 days ago
A) one
upvoted 0 times
...
...
Zena
1 months ago
I think the answer is B) zero because the code outputs nothing.
upvoted 0 times
...
Marget
1 months ago
I bet it's option D. Three hashes sounds about right. Time to show off my coding skills!
upvoted 0 times
Marcos
14 days ago
User 2: I'm going with option D. Three hashes for sure.
upvoted 0 times
...
Latia
15 days ago
User 1: I think it's option A. Just one hash.
upvoted 0 times
...
...
Trinidad
1 months ago
I'm not sure, but I think it might be C) five.
upvoted 0 times
...
Chun
1 months ago
I believe it's D) three because of the loops in the code.
upvoted 0 times
...
Dominga
2 months ago
Ugh, I hate these types of questions. Why can't they just give us a simple 'Hello, World!' program?
upvoted 0 times
...
Tran
2 months ago
I think the answer is A) one.
upvoted 0 times
...
Jesus
2 months ago
The code looks pretty straightforward, but I'm still not sure about the answer. Guess I'll have to give it a shot!
upvoted 0 times
Lorriane
16 days ago
I'm going with one hash.
upvoted 0 times
...
Wade
17 days ago
I believe it's five hashes.
upvoted 0 times
...
Danica
20 days ago
I think it outputs three hashes.
upvoted 0 times
...
...
Erasmo
2 months ago
Hmm, this is a tricky one. Let me think about this carefully.
upvoted 0 times
Natalie
1 months ago
User 3: I'm not sure, but I think it might be one hash.
upvoted 0 times
...
Justa
1 months ago
User 2: I believe it outputs five hashes.
upvoted 0 times
...
Ora
1 months ago
User 1: I think the code outputs three hashes.
upvoted 0 times
...
...

Save Cancel