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 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 (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
mplopez
Highly Voted 1 year, 4 months 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 6 times
...
Dempsdawg
Most Recent 8 months, 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 2 times
...
Valcon_doo_NoviSad
1 year, 1 month 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
1 year, 3 months ago
the answer is 2, I ran in IDE
upvoted 1 times
...
CristianCruz
1 year, 4 months ago
Selected Answer: B
answer is B
upvoted 1 times
...
Administrator_Of_Silly_Walks
1 year, 4 months 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
1 year, 2 months 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
1 year, 5 months 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
1 year, 6 months ago
Answer is 2 (with correction of code typo and indentation)
upvoted 1 times
...
Dinsha
1 year, 8 months ago
Selected Answer: A
It will throw error while exe ution
upvoted 1 times
...
Raeesa
2 years ago
I wrote a few days ago. There are no identation or 'issues ==' typos in the exam.
upvoted 3 times
Rizos
1 year, 8 months ago
This is true, I took the exam and failed. There are no typos or indentation issues.
upvoted 2 times
andr3
1 year, 8 months ago
how many new questions was on exam ?
upvoted 1 times
Rizos
1 year, 8 months ago
maybe 20
upvoted 2 times
andr3
1 year, 8 months ago
thanks and good luck next time
upvoted 2 times
...
...
...
...
...
N9
2 years, 2 months ago
Selected Answer: A
A is correct. == is required.
upvoted 1 times
...
666_m
2 years, 6 months ago
A is correct , for reason of invalid synthax
upvoted 1 times
...
macxsz
2 years, 7 months ago
should be if == answer: A. the code is erroneous
upvoted 2 times
...
Ram5678
2 years, 7 months ago
A is correct as the equality operator is wrong. It is supposed to be a == 5.
upvoted 1 times
...
rocky48
2 years, 8 months 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
3 years ago
a is correct since the equality operator is wrong
upvoted 1 times
...
Moonus
3 years, 2 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 ...