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

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

What is the expected output of the following snippet?

  • A. 3
  • B. 1
  • C. 2
  • D. the code is erroneous
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
locloc91
Highly Voted 4 years, 8 months ago
Since the else is indented incorrectly, the code will be erroneous!
upvoted 17 times
...
mplopez
Most Recent 9 months ago
Selected Answer: D
The "else" part is not correctly indented
upvoted 1 times
...
Ello2023
11 months, 1 week ago
Selected Answer: D
There are 2 mistakes Firstly, there is missed quotes Secondly, the else is not indented correctly
upvoted 1 times
...
Ello2023
11 months, 2 weeks ago
Selected Answer: D
Just tested this code and the "else:" has the wrong indentation and therefore, it never worked.
upvoted 1 times
...
varshu_0708
11 months, 2 weeks ago
Selected Answer: D
"else" indentation is not correct. so the answer is D. if the indentation is correct, the ans will be 3
upvoted 1 times
...
ivanbicalho
1 year, 2 months ago
Selected Answer: D
The indentation is not correct
upvoted 1 times
...
naveenbv80
1 year, 4 months ago
If the indentation is correct then answer is 3 a=2 if a>0: a+=1 else: a-=1 print(a) If the indentation is not correct, the answer is "the code will be erroneous" a=2 if a>0: a+=1 else: a-=1 print(a)
upvoted 4 times
...
N9
1 year, 7 months ago
Selected Answer: D
code is not indented properly. Output : line number <number> invalid syntax else: ^^^^
upvoted 1 times
...
PremJaguar
1 year, 9 months ago
The code should be erroniouse
upvoted 2 times
...
Jiansy90
1 year, 10 months ago
Answer is D, There is indentation mistake.
upvoted 1 times
...
palagus
1 year, 11 months ago
Selected Answer: D
The code is erroneous.
upvoted 2 times
...
666_m
1 year, 11 months ago
follow the indentation of the question, the answer is D
upvoted 1 times
...
macxsz
1 year, 11 months ago
indentation is incorrect: D. the code is erroneous
upvoted 1 times
...
gherulloa
1 year, 11 months ago
Selected Answer: D
Option D: if ran as in the question, it throws "invalid syntax" error
upvoted 2 times
...
Therizzzla
4 years, 3 months ago
In the answer given, the indentation error is fixed, therefore the answer would be 3. But because the else is not indented properly in the question, when you run the code it will give an error. Tried this in python itself and a compiler.
upvoted 3 times
...
Pygineer
4 years, 4 months ago
error, indentation error
upvoted 2 times
...
SophieSu
4 years, 4 months ago
3 is the correct 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 ...