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 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
5 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
5 months ago
Marget
upvoted 0 times
Gail
3 months ago
D) three
upvoted 0 times
...
Gail
4 months ago
B) zero (the code outputs nothing)
upvoted 0 times
...
Gail
4 months ago
A) one
upvoted 0 times
...
Samira
4 months ago
D) three
upvoted 0 times
...
Samira
4 months ago
B) zero (the code outputs nothing)
upvoted 0 times
...
Samira
4 months ago
A) one
upvoted 0 times
...
...
Zena
5 months ago
I think the answer is B) zero because the code outputs nothing.
upvoted 0 times
...
Marget
5 months ago
I bet it's option D. Three hashes sounds about right. Time to show off my coding skills!
upvoted 0 times
Marcos
4 months ago
I'm going with option D. Three hashes for sure.
upvoted 0 times
...
Latia
4 months ago
I think it's option A. Just one hash.
upvoted 0 times
...
...
Trinidad
5 months ago
I'm not sure, but I think it might be C) five.
upvoted 0 times
...
Chun
5 months ago
I believe it's D) three because of the loops in the code.
upvoted 0 times
...
Dominga
5 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
5 months ago
I think the answer is A) one.
upvoted 0 times
...
Jesus
5 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
4 months ago
I'm going with one hash.
upvoted 0 times
...
Wade
4 months ago
I believe it's five hashes.
upvoted 0 times
...
Danica
4 months ago
I think it outputs three hashes.
upvoted 0 times
...
...
Erasmo
6 months ago
Hmm, this is a tricky one. Let me think about this carefully.
upvoted 0 times
Natalie
5 months ago
I'm not sure, but I think it might be one hash.
upvoted 0 times
...
Justa
5 months ago
I believe it outputs five hashes.
upvoted 0 times
...
Ora
5 months ago
I think the code outputs three hashes.
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