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 7 discussion

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

What is the expected output of the following snippet?

  • A. the code is erroneous
  • B. 3
  • C. 7
  • D. 15
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
mplopez
Highly Voted 8 months, 1 week ago
Selected Answer: A
In this case, the correct answer is A, because inside the if for comparing the result of the modulus must be if i % 2 == 0: .....
upvoted 5 times
...
Dempsdawg
Most Recent 1 week ago
Selected Answer: A
The answer is A because it says "i%2=0" which causes a a error. it should be "i%2==0"
upvoted 1 times
...
Valcon_doo_NoviSad
5 months ago
Selected Answer: A
Answer is A because we have "if i % 2 = 0" and it should be "if i % 2 == 0" Even if we had if i % 2 == 0 having break command inside skips the else block
upvoted 2 times
...
Kusme
7 months ago
the answer is 2, I ran in IDE
upvoted 1 times
...
CristianCruz
8 months, 2 weeks ago
Selected Answer: B
answer is B
upvoted 1 times
...
Administrator_Of_Silly_Walks
8 months, 3 weeks ago
Selected Answer: A
There are two major typos that I can see: 1) "if i % 2 = 0" should be "if i % 2 == 0" 2) The "if" and "else" statements aren't lined up correctly.
upvoted 1 times
Almartmart
6 months, 1 week ago
The second one isn't a typo. The else is part of the while, which gets executed the moment that you exit the loop.
upvoted 2 times
...
...
Ello2023
9 months, 2 weeks ago
Selected Answer: A
A. the code is erroneous There is no indentation error, however the line that has % 2 = 0 should be % 2 == 0
upvoted 1 times
...
DrMKG
10 months, 1 week ago
Answer is 2 (with correction of code typo and indentation)
upvoted 1 times
...
Dinsha
1 year ago
Selected Answer: A
It will throw error while exe ution
upvoted 1 times
...
Raeesa
1 year, 4 months ago
I wrote a few days ago. There are no identation or 'issues ==' typos in the exam.
upvoted 3 times
Rizos
1 year ago
This is true, I took the exam and failed. There are no typos or indentation issues.
upvoted 2 times
andr3
1 year ago
how many new questions was on exam ?
upvoted 1 times
Rizos
1 year ago
maybe 20
upvoted 2 times
andr3
1 year ago
thanks and good luck next time
upvoted 2 times
...
...
...
...
...
N9
1 year, 6 months ago
Selected Answer: A
A is correct. == is required.
upvoted 1 times
...
666_m
1 year, 10 months ago
A is correct , for reason of invalid synthax
upvoted 1 times
...
macxsz
1 year, 11 months ago
should be if == answer: A. the code is erroneous
upvoted 2 times
...
Ram5678
1 year, 11 months ago
A is correct as the equality operator is wrong. It is supposed to be a == 5.
upvoted 1 times
...
rocky48
2 years ago
Selected Answer: A
Notice that the following snippet is: if i%2=0: that raise a SyntaxError You would be right if the snippet were: if i % 2 == 0:
upvoted 1 times
...
technoguy
2 years, 4 months ago
a is correct since the equality operator is wrong
upvoted 1 times
...
Moonus
2 years, 6 months ago
Answer is A
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 ...