PCAP Exam QuestionsBrowse all questions from this exam

PCAP Exam - Question 10


What is the expected output of the following snippet?

Show Answer
Correct Answer: A

A

Discussion

17 comments
Sign in to comment
locloc91Option: D
Aug 14, 2019

Since the else is indented incorrectly, the code will be erroneous!

naveenbv80Option: A
Dec 2, 2022

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)

TherizzzlaOption: D
Jan 8, 2020

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.

PygineerOption: D
Dec 5, 2019

error, indentation error

gherulloaOption: D
Apr 27, 2022

Option D: if ran as in the question, it throws "invalid syntax" error

palagusOption: D
May 24, 2022

The code is erroneous.

PremJaguarOption: D
Jul 18, 2022

The code should be erroniouse

SophieSuOption: A
Dec 3, 2019

3 is the correct answer.

macxszOption: D
May 3, 2022

indentation is incorrect: D. the code is erroneous

666_mOption: D
May 16, 2022

follow the indentation of the question, the answer is D

Jiansy90Option: D
Jun 22, 2022

Answer is D, There is indentation mistake.

N9Option: D
Sep 3, 2022

code is not indented properly. Output : line number <number> invalid syntax else: ^^^^

ivanbicalhoOption: D
Feb 19, 2023

The indentation is not correct

varshu_0708Option: D
May 9, 2023

"else" indentation is not correct. so the answer is D. if the indentation is correct, the ans will be 3

Ello2023Option: D
May 10, 2023

Just tested this code and the "else:" has the wrong indentation and therefore, it never worked.

Ello2023Option: D
May 16, 2023

There are 2 mistakes Firstly, there is missed quotes Secondly, the else is not indented correctly

mplopezOption: D
Jul 23, 2023

The "else" part is not correctly indented