Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam PCAP All Questions

View all questions & answers for the PCAP exam

Exam PCAP topic 1 question 3 discussion

Actual exam question from Python Institute's PCAP
Question #: 3
Topic #: 1
[All PCAP Questions]

What will the value of the i variable be when the following loop finishes its execution?

  • A. 10
  • B. the variable becomes unavailable
  • C. 11
  • D. 9
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
Avidulam
Highly Voted 4 years, 7 months ago
The answer is 9.
upvoted 25 times
Dushank
3 years, 9 months ago
Just try to print the value of i after the loop, you would get 9 as result. <code> for i in range(10): pass print(i) </code>
upvoted 6 times
...
...
HarrySoni
Highly Voted 4 years, 7 months ago
9 is the Answer. Pass only means there are no statements to execute it does not means the variable is unavailable. Try a Print statemnt Print(i) after the For Loop and there is your result.
upvoted 12 times
imsaad
4 years, 2 months ago
Correct
upvoted 2 times
...
...
megan_mai
Most Recent 3 weeks ago
Selected Answer: D
Answers are CD for i in range (10): pass print(i) #output: 9
upvoted 1 times
...
86b907f
4 months, 3 weeks ago
Selected Answer: D
I'm seeing answer B, C and D in the comments ... strange ?
upvoted 1 times
...
Dempsdawg
7 months, 2 weeks ago
Selected Answer: B
for i in range(10): pass #This pass will make it C because there is NO print function
upvoted 1 times
...
Dempsdawg
7 months, 2 weeks ago
Selected Answer: C
for i in range(10): pass Sub pass for print(i): 0 1 2 3 4 5 6 7 8 9
upvoted 1 times
...
Irgond07
9 months ago
C:\Python_Local\Python_CMD\PCAP>more pcep1.py for i in range(10): pass print(i) C:\Python_Local\Python_CMD\PCAP>python pcep1.py 0 1 2 3 4 5 6 7 8 9 C:\Python_Local\Python_CMD\PCAP>
upvoted 1 times
...
eskimolight
11 months, 1 week ago
Can someone confirm if this exam code is PCAP-31-03 ?
upvoted 2 times
...
Bere
1 year ago
Selected Answer: D
for i in range(10): print(f"for-i: {i}") pass print(f"final-i: {i}") for-i: 0 for-i: 1 for-i: 2 for-i: 3 for-i: 4 for-i: 5 for-i: 6 for-i: 7 for-i: 8 for-i: 9 final-i: 9
upvoted 1 times
...
KentuckyFriedRice
1 year, 1 month ago
The answer is B because i is an interation variable. Once the loop has finished execution, it is no longer accessible.
upvoted 1 times
...
mplopez
1 year, 3 months ago
Selected Answer: D
The for loop start to count from 0 and de range of members that must to iterate are 10 loops, that says the loop begins in 0 and finish in 9.
upvoted 1 times
...
DrMKG
1 year, 5 months ago
Answer is 9
upvoted 1 times
...
Sadaiyan
1 year, 5 months ago
Selected Answer: D
Answer : D : 9
upvoted 1 times
...
Dinsha
1 year, 7 months ago
Selected Answer: D
Answer 9
upvoted 1 times
...
spiderking123
1 year, 8 months ago
Selected Answer: D
The answer is 9
upvoted 1 times
...
Blippen
1 year, 9 months ago
Selected Answer: D
9 in the answer
upvoted 1 times
...
Adeshina
1 year, 10 months ago
D is the right answer. The value of the i variable when the for loop finishes its execution will be 9. This is because the range(10) function generates a sequence of numbers from 0 to 9, and the for loop will iterate over this sequence, with the variable i taking on each value in turn. When the for loop reaches the end of the sequence, it will stop, and the value of i at that point will be 9.
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...