0

Confusing question in the course "Python3"

I'm afraid following question is confusing: ===== Which errors occur in this code? try: print(1 / 0) except ZeroDivisionError: raise ValueError ===== I think "error" is different concept from "exception". (In many cases, an error produces an exception. But, they are not identical.) In the code, 'error' is "1/0', but ValaueError is intentionally thrown exception. On the other hand, if the question were the "Which exceptions are thrown by this code?, it can also be confusing. Because ZeroDivisionError is thrown, but consumed by try/except. So, it can be ambiguous whether consumed exception should be included to the answer... (The exception finally produced by this code is ValueError, only.) I felt strange feeling from the current question, but I cannot propose the better one. "What are the exceptions thrown during executing this code?" Maybe?

21st Apr 2018, 1:54 AM
Hideyuki Koinuma
9 Réponses
+ 5
Hi Hideyuki, you are correct in your assesment. I have had similar experiences with ambiguous wording on other courses. for instance "constant variable". In your description of the problem you explain clearly that you understand what is happening with Errors, Exceptions and try except statements. Sololearn is a free app, and as such one cannot expect everything to be 100% all the time. Having said that I'm sure they want to improve and if you send your issue to info@sololearn.com they might restate the question to be more clear.
21st Apr 2018, 5:20 AM
Louis
Louis - avatar
+ 3
is the answer 2
27th Jun 2019, 11:49 AM
Ubaydullah Patel
Ubaydullah Patel - avatar
+ 2
ZeroDivisionError and ValueError
5th Sep 2019, 6:41 AM
Kamlesh Kumar
Kamlesh Kumar - avatar
+ 1
A ZeroDivisionError will occur as the denominator is indeed 0. But what action do we take when the ZeroDivisionError occurs? We raised a ValueError.
3rd Dec 2020, 10:11 AM
Lola
0
When the above code is run, notice since its a try-except block, the except line is raised, meaning the ZeroDivisionError is raised. What is given inside the except block is upto you. Here, you chose to raise an error named ValueError.
9th May 2018, 4:49 PM
Lola
0
idk
4th Jul 2019, 10:49 AM
Hamza Hafez
Hamza Hafez - avatar
0
try: print(1) print(20 / 0) print(2) except ZeroDivisionError: print(3) finally: print(4) -> 2
9th Oct 2019, 2:22 PM
Karthik Thota
0
ı thınk ıts differnt for me answear is 2
17th Jan 2020, 2:18 PM
abdullah
0
answer is 2
10th Feb 2020, 8:12 PM
Disha Prajapati
Disha Prajapati - avatar