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

GIAC Exam GPYC Topic 4 Question 54 Discussion

Actual exam question for GIAC's GPYC exam
Question #: 54
Topic #: 4
[All GPYC Questions]

What will be the value of the i variable when the while loop finishes its execution0

i = 0

while i != 0:

1 = 1-1

else:

i = i + 1

Show Suggested Answer Hide Answer
Suggested Answer: A

Contribute your Thoughts:

Bok
3 months ago
B) 0 is the answer. The loop condition i != 0 will become false when i reaches 0, and the loop will terminate.
upvoted 0 times
Yolando
3 months ago
B
upvoted 0 times
...
Yolando
3 months ago
A
upvoted 0 times
...
...
Emerson
3 months ago
No, the else statement will not be executed because the while condition is not met.
upvoted 0 times
...
Elli
3 months ago
Haha, D) the variable becomes unavailable? Really? That's a good one, but I don't think that's how it works.
upvoted 0 times
Geraldine
2 months ago
C) 2
upvoted 0 times
...
Caitlin
3 months ago
B) 0
upvoted 0 times
...
Kattie
3 months ago
A) 1
upvoted 0 times
...
...
King
4 months ago
But what about the else statement? Doesn't it increment i by 1?
upvoted 0 times
...
Anabel
4 months ago
I agree with Emerson, the while loop will not execute so i will remain 0.
upvoted 0 times
...
Rusty
4 months ago
Wait, did you say the loop runs indefinitely? I must have been day-dreaming during the lecture on while loops. *facepalm*
upvoted 0 times
Felicidad
3 months ago
Yeah, the loop will eventually end with i being 0.
upvoted 0 times
...
Leslie
3 months ago
Don't worry, the loop will actually finish with i equal to 0.
upvoted 0 times
...
...
Emerson
4 months ago
I think the value of i will be 0.
upvoted 0 times
...
Jade
4 months ago
The correct answer is definitely B) 0. The loop will run once, decrementing i to -1, and then the else block will execute, setting i to 1. So when the loop finishes, i will be 0.
upvoted 0 times
Salley
4 months ago
Actually, the correct answer is B) 0
upvoted 0 times
...
Lajuana
4 months ago
I'm pretty sure it's C) 2
upvoted 0 times
...
Kimi
4 months ago
No, I believe it's B) 0
upvoted 0 times
...
Annmarie
4 months ago
I think the answer is A) 1
upvoted 0 times
...
...

Save Cancel