Posts

Python OOP Part 1

Python is an object-oriented programming language.  Object-oriented programming  (OOP) focuses on creating reusable patterns of code. Class  — A blueprint created by a programmer for an object. This defines a set of attributes that will characterize any object that is instantiated from this class. Object  — An instance of a class. This is the realized version of the class, where the class is manifested in the program. We define classes by using the  class  keyword, similar to how we  define functions  by using the  def keyword. Objects can store data using ordinary variables that  belong  to the object. Variables that belong to an object or class are referred to as  fields . Objects can also have functionality by using functions that  belong to a class. Such functions are called  methods  of the class. This terminology is important because it helps us to differentiate between functions...

Health Benefit of Products made from Sea buckthron

Image
The Health Benefits of Omega What is Omega-3 Fatty Acid? Omega-3 fatty acid (Alpha-linolenic acid) is an essential fatty acid that plays an important role in brain function and may help you fight against cardiovascular disease  [ 1 ] . The American Heart Association recommends a diet in which fatty fish, like salmon, herring, sardines and tuna are consumed at least twice a week. While these foods are high in omega-3 fatty acid, I personally do not agree with this recommendation as fish can be contaminated and may be high in  mercury , which can have detrimental health effects. Plus, I believe a  raw food diet  consisting of little to no meat is better for the human body. Health Benefits of Omega-3 Fatty Acid Research on the health benefits of omega-3 fatty acid have shown that it may be useful for supporting the following: Asthma Diabetes Arthritis Osteoporosis Some Cancers Skin Disorders High Cholesterol ...

Exception Handling in Python Part 2

Image
Exception Handling in Python Example: try:     linux_interaction() except AssertionError as error:     print(error) else:     try:         with open('file.log') as file:             read_data = file.read()     except FileNotFoundError as fnf_error:         print(fnf_error) finally:     print('Cleaning up, irrespective of any exceptions.')   Summing Up   After seeing the difference between syntax errors and exceptions, you learned about various ways to raise, catch, and handle exceptions in Python. In this article, you saw the following options: raise  allows you to throw an exception at any time. assert  enables you to verify if a certain condition is met and throw an exception if it isn’t. In the  try ...

Exception Handling in Python Part 1

Image
Exception Handling in Python What is an Exception? An exception is an error that happens during execution of a program. When that error occurs, Python generate an exception that can be handled, which avoids your program to crash. Exceptions are convenient in many ways for handling errors and special conditions in a program. When you think that you have a code which can produce an error then you can use exception handling. Python has many built-in exceptions which forces your program to output an error when something in it goes wrong. When these exceptions occur, it causes the current process to stop and passes it to the calling process until it is handled. If not handled, our program will crash. For example, if function A calls function B which in turn calls function C and an exception occurs in function C. If it is not handled in C, the exception passes to B and then to A. If never handled, an error message is spit out and our program comes to a sudden, u...