Recent Posts

Exceptions & Comments



Exceptions 

How to handle errors in your python program

So , for example, we are posting an application with a very simple code..The user need to put the cost of a pizza



But suddenly the user put another different non-numerical value: this will crash your application


Code 1 basically is telling us that the program crashed because the user added a different value.

We need to correct with exceptions:



Now we don't see any error in our program .., and the code is 0 again


We can see that we can find different exceptions errors.. For example:


There are several ways to fix this:



Because  we have  exit code "0" , we can tell our program didn't crash


Comments

Comments in Python start with the hash character, # , and extend to the end of the physical line. A comment may appear at the start of a line or following whitespace or code, but not within a string literal.

Single-line comments are created simply by beginning a line with the hash (#) character, and they are automatically terminated by the end of line. Comments that span multiple lines – used to explain things in more detail – are created by adding a delimiter (“””) on each end of the comment.

As a common rule, don't put stuff in comment line that would be very obvious or repetitive




You should use it to explain something, reminder notes, or to explain other developer to do something with the code


Exceptions & Comments Exceptions & Comments Reviewed by ohhhvictor on May 09, 2019 Rating: 5

No comments:

Facebook

 photo imagen120.jpg
Theme images by 5ugarless. Powered by Blogger.