Q. Evaluate the following expression (stepwise) on paper first. Then execute it in Python shell.
Compare your result with Python's. State reasons


4 * len ("Problem1") / (len ("Python") % 3) + 2.0

Find out the final output and its type.


Your Evaluation :-

4 * 8 / 0 + 2.0
32 / 0 + 2.0
division by zero (Error)

Reason :- It will give error that division by zero (Error).


Output:-
 
>>> 4 * len ("Problem1") / (len ("Python") % 3) + 2.0
ZeroDivisionError: division by zero

Output's data type :- ERROR

Python's result (Paste the screenshot of expression's evaluation by Python's shell) :-

>>> 4 * len ("Problem1") / (len ("Python") % 3) + 2.0
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    4 * len ("Problem1") / (len ("Python") % 3) + 2.0
ZeroDivisionError: division by zero

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post