If there is an error in the Python code - why does the whole program shut down? and notify of a possible error?
In the example here there are two print() commands. If one is valid but the other is not the console only displays an error and does not ‘print’ the correct result.
Thanks in advance.
If something goes wrong in some sequence of steps that rely on each other, then there’s no meaningful way to continue, you want that to stop.
If it’s a bug then fix the bug.
If something was wrong about the outside world, then you might ignore the request that causes something to go wrong, and continue with the next one. Example: permission denied when opening a file -> don’t open that file, continue with next file, assuming that they are independent units of work and that it makes some kind of sense to continue.
I agree like in life if a machine a part of it is spiolt the rest will work unless it is a important part of the machine speaking as someone who understands basic syntax
Would there be any instances when you could bypass an error to keep the program running? If so, how and why?
Parenthesis within parenthesis
print(“Then there he stood, surveying the crop fields before saying “We have an infestation.””)
print(‘line 1 \n\nline 3’)
counter = 0
counter += 10
This is equivalent to
counter = 0
counter = counter + 10
The operator will also perform string concatenation
message = "Part 1 of message "
message += “Part 2 of message”
numerator = 100
denominator = 0
bad_results = numerator / denominator
zero = 8 % 4
nonzero = 12 % 5
first = "Hello "
second = “World”
result = first + second
long_result = first + second + “!”
pi = 3.14159
message = "The pressure is "
valve_pressure = 30
print(message + str(valve_pressure))
message_string = “Hello there”
message_string = “Hasta la vista”