<jupyter_start><jupyter_text>Python Objects and Their UseWith today's lesson we will start learning object oriented in Python by introducing Objects in Python. - Objects are the fundamental component of object-oriented programming.In this lesson we will discuss about the Objects only, in later lectures I will introduce you the Object Oriented Python. - All objects have certain __attributes__ and __behavior__.Let's examine the real life example: Our object is a Car;__Attributes:__- It's color- Number of miles driven- current location__Behaviours:__- Driving the car (Change the miles driven, change location)- Painting the car (Changing the color)In similar fashion, Objects in computer science contains a set of attributes, stored in a set of __instance variables__, and a set of functions called __methods__ that provide its behaviour. For instance, when we talked about lists, we mentioned ```sort(list)``` function. It's a procerdural programming approach with two distinct entities a sort function and a list to pass it. But in Object-oriented programming approach, the ```sort``` routine would be part of the object containing the list like other methods for lists;- ```append(x)```- ```remove(x)```- ```reverse()```- ```sort()```<jupyter_code>lst = [10, 4, 7, 8, 9, 13, 1, 0, 78, 5, 58]
lst.append(55)
lst
lst.remove(4)
lst
lst.reverse()
lst
lst.sort()
lst<jupyter_output><empty_output><jupyter_text>---In Python, objects are represented as a _reference_ to an object in memory.A __reference__ is a value that references, or “points to,” the location of another entity.T hus, when a new object in Python is created, two entities are stored—the object, and a variable holding a reference to the object. All access to the object is through the reference value.We can get the reference value of a variable (that is, the location in which the corresponding object is stored) by use of __built-in function ```id```__.<jupyter_code>n = 10
id(n)
k = 10
id(k)
s = 20
id(s)<jupyter_output><empty_output><jupyter_text>After introducing the basic concept of objects, now we can continue exploring Python. In this section we will look at what is modular desing, why is important and how to do it in Python Modular Design__Modular Design for Orbiter Flight Computer Software__:![Modular Design for Orbiter Flight Computer Software](https://history.nasa.gov/computers/p114.jpg)An important aspect of well-designed software is that programs are designed as a collection of modules. The term _“module”_ broadly speaking, refers to the design and/or implementation of specific functionality to be incorporated into a program.While an individual function may be considered a module, modules generally consists of a collection of functions (or other entities).Every module needs to provide a specifi cation of how it is to be used. This is referred to as the module’s __interface__.A __docstring__ is a string literal denoted by triple quotes given as the first line of certain program elements.<jupyter_code>def numPrimes(start, end):
    """ Returns the number of primes between start and end. """
    return 0
print(numPrimes.__doc__)<jupyter_output>Returns the number of primes between start and end.<jupyter_text>- A __Python module__ is a file containing Python definitions and statements. - The Python Standard Library contains a set of predefined __standard (built-in) modules__.---- A __namespace__ provides a context for a set of identifiers. Every module in Python has its own namespace. - A __name clash__ is when two otherwise distinct entities with the same identifier become part of the same scope.![Name Clash](https://raw.githubusercontent.com/NAU-ACM/IntroductionToPython/master/images/name_clash.png)![Namespaces](https://raw.githubusercontent.com/NAU-ACM/IntroductionToPython/master/images/namespaces.png)---With the ```import modulename``` form of import in Python, the namespace of the imported module becomes available to, but does not become part of, the namespace of the importing module.<jupyter_code>import math
factortial(5)
import math 
math.factorial(5)<jupyter_output><empty_output><jupyter_text>The  "from-import" Form of ImportWith the ```from-import``` form of import, imported identifiers become part of the importing module’s namespace. Because of the possibility of name clashes, ```import modulename``` is the preferred form of import in Python.<jupyter_code>from math import factorial
factorial(5) # Works but vulnerable to name clashes
def factorial(n):
    print('my factorial function')
factorial(5) # It's not what I wanted
math.factorial(5)
from math import factorial as fact
fact(5)
def factorial(n):
    print('my factorial function')
factorial(5)
fact(5)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07472480948348857, 'fraction_numerical': 0.007620660457239628, 'mean_word_length': 5.393775372124493, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '450666', 'license': 'MIT', 'n_tokens_mistral': 1274, 'n_tokens_neox': 1212, 'n_words': 612, 'path': 'Python_Basics/07_Modular_Design.ipynb', 'repo_name': 'eneskemalergin/Data_Science_with_Python', 'size': '4724'}