reading-notes

Dunder methods:

also known as magic methods or special methods, in Python are used to define the behavior of objects in response to certain operators or built-in functions. These methods are indicated by double underscores (dunder) both before and after the method name. They allow you to customize the behavior of objects and enable you to perform various operations on them.
One commonly used dunder method is __init.__ It is the constructor method for a class and is called when a new instance of the class is created. It initializes the attributes of the object. Here’s an example:

class Rectangle:
   def __init__(self, width, height):
     self.width = width
     self.height = height

   def area(self):
      return self.width * self.height

rect = Rectangle(5, 3)
print(rect.area()) 

#Output: 15

</code>

In the example above, init initializes the width and height attributes of a Rectangle object when it is created.

plagiarism or the lack of proper attribution. If the AI guru in the video used code, content, or ideas from other developers without giving them credit, it would be considered unethical. To avoid such ethical issues, it is essential to properly attribute and give credit to the original developers when using their work.

The Python statistics module

import statistics

data = [2, 4, 6, 8, 10]
mean_value = statistics.mean(data)
print(mean_value)  

#Output: 6

</code>

In the example above, the mean function from the statistics module is used to calculate the mean (average) value of the data list.