First, check the following code-
a = 101 / 0
PythonRun this code-
Output:
raceback (most recent call last):
File "example.py", line 1, in <module>
a = 101 / 0
~~~~^~~
ZeroDivisionError: division by zero
PlaintextWhat just happened?
Or check the following code example-
discount = 20
price = input("Enter price of the product: ")
calculated_price = float(price) - discount
print(calculated_price)
PythonRun the program, and enter 100-
Enter price of the product: 100
80.0
PlaintextNow run the program again and enter some string as input. Here we have entered “some string here”-
Enter price of the product: some string here
Traceback (most recent call last):
File "bigboxexample.py", line 5, in <module>
calculated_price = float(price) - discount
^^^^^^^^^^^^
ValueError: could not convert string to float: 'some string here'
Plaintext