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

Unlimited Access

Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.

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: B 🗳️
Reference:
https://www.programiz.com/python-programming/pass-statement

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, 1 month ago
The answer is 9.
upvoted 25 times
Dushank
3 years, 3 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 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
3 years, 8 months ago
Correct
upvoted 2 times
...
...
Dempsdawg
Most Recent 1 month 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
1 month 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
2 months, 3 weeks 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
5 months ago
Can someone confirm if this exam code is PCAP-31-03 ?
upvoted 2 times
...
Bere
6 months 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
7 months, 2 weeks 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
9 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
11 months ago
Answer is 9
upvoted 1 times
...
Sadaiyan
11 months, 3 weeks ago
Selected Answer: D
Answer : D : 9
upvoted 1 times
...
Dinsha
1 year, 1 month ago
Selected Answer: D
Answer 9
upvoted 1 times
...
spiderking123
1 year, 1 month ago
Selected Answer: D
The answer is 9
upvoted 1 times
...
Blippen
1 year, 3 months ago
Selected Answer: D
9 in the answer
upvoted 1 times
...
Adeshina
1 year, 4 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
...
ciccio_benzina
1 year, 7 months ago
it's 9!
upvoted 1 times
...
alfonsocav1982
1 year, 7 months ago
9 in the answer
upvoted 1 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 ...