Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 51

DAY-1: 15/02/2024

TOPIC:

INTRODUCTION TO AI,ML,DL

OBSERVATIONS:

ARTIFICIAL INTELLIGENCE-

The ability of a machine to imitate human behaviour

MACHINE LEARNING-

Subset of AI, Application of AI that learns and improves using experience

DEEP LEARNING-

Subset of ML, its used for complex problems


DAY-2:16/02/2024

TOPIC:

TYPES OF MACHINE LEARNING

 Supervised ML
Data format-
Supervised ML works on labelled data(where input and output(prediction) are available.
This ML model understands the relation between input and output data.
EX- weather prediction, loan prediction

 Unsupervised ML-
Input data is available but output is not available.
Segmentation of data.

 Reinforcement ML-
Based on decision making in real time.
Input data(Labelled data) available.
Works based on reward system.
Right decision- reward to agent
Wrong decision- penalty to agent
EX- self driving car
DAY-3:19/02/2024

TOPIC:

PROGRAMMING LANGUAGE-

OBSERVATIONS:

LANGUAGE- Tool for communication/ medium for communication


NATURAL LANGUAGE- Human understandable language.
 Computer’s doesn’t understand natural language
 Computer’s only understands programming language.

Humans can also understands programming language.

PROGRAM-
A set of instructions to follow/ A set of information given.
Types of programming languages-

Java, C, C++,JS, PYTON, RUBY, etc..

PYTON- most suitable way for data science program.


DAY-4:20/02/2024

TOPIC:

TERMINAL AND JUPYTER

OBSERVATION:

Terminal is the alternate way of interacting with computer/pc.

In Terminal we interact with computer using computer commands(without mouse pointers)

Instructing the computer what to do.

In terminal we can open any application and see the execution of the code in the terminal.

JUPYTER is mainly used for creating ML applications

Earlier it was called as IPYTHON

Supports 40+ languages

JUPYTER is mostly used for PYTHON.

IPYKERNEL is an inbuild terminal in notebook to generate output in the notebook.


DAY-5:21/02/2024

TOPIC:

WHAT IS PYTHON?

OBSERVATION:

PYTHON:

 Programming language
 Using
 INTERPRETED- Dependent on interpreter for code execution(running code)
 HIGH LEVEL- Contains Compiler or interpreter
 MULTI-PURPOSE- 1-web Development
2-App Development
3-Server Management
4-Data science
5-Data engineering
6-IOT
 Version 3 is used For Data science.
DAY-6:

TOPIC:

PROPERTIES OF PYTHON
OBSERVATIONS:

DYNAMICALLY TYPED LANGUAGE-

We don’t require to specify the data type before writing the code & we can reassign another data
type to the variable.

INDENTATION-

There should be no space at the beginning of the code. The compiler generates error.

USE OF INDENTATION-

Define code blocks

Define scope of control structures(functions, if-else, loops (for, while)

PUNTUATION-

Don’t use punctuations at the end of the code. The compiler generates error.

Print(x=10).
DAY-7:

TOPIC:

VARIABLES AND IDENTIFIERS

OBSERVATIONS:

VARIABLES:

-Stores data/value

X=10

Where X is variable name & 10 is variable value.

IDENTIFIERS
-user defined name

-Variables, functions, class are some of the identifiers

RULES OF VARIABLES/IDENTIFIERS
-should only contain alphabets, numbers, underscore

-should starts with underscore or alphabet

-should not be of a keyword(keywords are the characters that have a special meaning in PYTHON)

-should not contains space in between the characters

-if we want to distinguish/ separate use underscore or camelCase (VijayPandu, using capital letter at
the beginning of separation).

-A literal is assigned to variable using (=).


DAY-8:

TOPIC:

ARITHMTICS OPERATORS
LOGICAL OPERATORS
BITWISE OPERATORS-

IDENTITY OPERATORS
ASSIGNMENT OPPERATORS-
MEMBERSHIP OPERATOR
OBSERVATIONS:

ARITHMTICS OPERATORS
(+ , - , * , / , // , % , **)

LOGICAL OPERATORS
(and , or , not)

BITWISE OPERATORS-
BITWISE ‘&’ OPERATOR-

BITWISE ‘OR’ OPERATOR-

BITWISE XOR OPERATOR-(^)

COMPLEMENT OPERATOR(~)-

LEFT SHIFT OPERATOR(<<)

RIGHT SHIFT OPERATOR(>>)

IDENTITY OPERATORS
(is , ==)

ASSIGNMENT OPPERATORS-
‘=’ – Variable Assignment-

‘+=’- INCREMENT-

‘-=’- DECREMENT-

‘*=’- MULTIPLICATION-

‘/=’- DIVISION-

‘//=’- SPECIAL DIVISION-

‘**=’- EXPONENT-

‘&=’-bitwise & operator

‘|=’ – bitwise or operator-

‘^=’ -XOR operator

‘<<=’-LEFT SHIFT

‘>>=’-RIGHT SHIFT

MEMBERSHIP OPERATOR
in and not in
DAY-9:
Topic:
String
Observation:
 A sequence of characters
 These strings are internally stored as a combination of 0’s & 1’s.a -65, b- 66,c- 67,etc
 These conversion is encoding and reverse is decoding
 Encoding methods=ASCII and UNICODE.
 Python doesn’t have character data type like other programming language.
 The ascii code of a=65 ,b=66,……and soon
DAY-10:
Some bulit in functions of string
Observations:
UPPER()-

This function helps in making all the characters in string to Uppercase letters.

LOWER()-

This function helps in making all the characters in string to lowercase letters.

TITLE-

This Function makes the 1st letter of every word to caps.

COUNT-

To count the number of occurrence of the sub-string in main string

FIND-

Helps to find the staring index position of the sub string in main string
DAY-11:
Topic :
Lists
Observations:
LISTS
 List is a collection of data in python which are defined using [ ] and collect the various
elements inside it.
 We can store multiple values in a single variable.
 Each element in the [ ] is separated by ‘ , ‘
 DUPLICATED VALUES- Lists allows duplicate values
 ORDERED- lists are always main order in element (sorting)
 INDEXING- Indexing can be used to access the elements in the lists.
 OBJECTS- lists can contain any objects including numbers, strings, tuples & even other lists.
 CHANGEABLE(MUTABLE)- Can be changed (add or del or change the place the place or
update)
 EXAMPLE: [1,2,3,4,5]
DAY-12:
Some bulit in methods of lists
Observation:
APPEND:

Append() is used to add a single element at the end of the list.

EXTEND:

Extend is used to extend the current list with multiple element

POP():

This function is used to remove the element in a list.

COPY:

It is used to copy the list in a different memory location.

DEEP COPY:

Used to copy the list in a new memory location.Even the nested lists are also copied in a new
memory location. To use deepcopy uh need to import copy module in python.

CLEAR:

Used to clear all the element of a list


DAY-13:
TUPLE:
OBSERVATIONS:

 .Tuple is a collection of data in which data is been indexed and it is immutable.


 It is denoted by ( ).
 Once we declare the tuple, we can not edit the data.
DAY-14:
PACKING & UNPACKING:

Observations:
PACKING:

It is helpful in packing the elements in a tuple.

a=10

b=12

t1=(a,b)

print(t1,type(t1))

output= (10,12)<class ‘tuple’>

UNPACKING:

t1=(1,2,3)

p,q,r=t1

print(p)

print(q)

print(r)

output= 1 2 3

NOTE: during unpacking we should take all number of variables(the variables are 2 or 4 but the
element in tuple is 3 ) to get the desired output orelse the result will be error
DAY-15:
SETS{}:
Observations:
 Sets are like lists which is used to store the collection of data/elements
 We declare sets using { }
 NO DUPLICATES: It doesn’t allow duplicate values.
 UNORDERED: It do not maintain the assigned order.
 UNINDEXED: It do not allow indexing
 MUTABLE/IMMUTABLE: sets are mutable with a condition.we can add/remove elements in
the sets but we can not change the elements in the sets because indexing is not supported.
DAY-16:

Bulit in methods of sets()

Observations:

UPDATE():

Using update we can add more than 1 element at a time in a set.

REMOVE:

Using remove() we can remove an element in a set. If the element is not presented in a set then it
shows error.

DISCARD:

Using discard() we can remove an element in a set but unlike remove it doesn’t show error if the
element is not presented in a set.

SORT:

It is used to sort the elements in the set and it returns the output as a list.

POP()

Pop is used to remove an element in the set randomly.


DAY-17:

DICTIONARY:
Observations:
 Dictionary are the collection of data which contains key-value pairs.
 Dictionaries are ordered, indexable and mutable.
 Don’t allow duplicates
 Defined using { }
Day-18:

Bulit in methods of dictionary

OBSERVATION:

GET():

Used to access the value using the variable name and key in the dictionary, if the key is not present in
the dictionary then the output will be none.

POPITEM():

It is used to remove the last item in the dictionary

DEL():

It used to delete a element in the dictionary


DAY-19:

CONDITIONAL STATEMENT:

OBSERVATIONS:

Conditional statements are used to control flow of the program. They execute the blocks of code
based on the truthfulness of the conditional statement.

PYTHON INDENTATION:

In python, the code blocks are defined by a set of common or consistent number of spaces. Those
spaces are called PYTHON INDENTATION

IF STATEMENT:

The if keyword is used to check the statement and execute the subsequent block of code based on
the truthfulness of the statement.

IF-ELSE:

If-else is used to run a program even if the condition is false.

NESTED IF ELSE-

If we have more conditions to test ,we can use nested if-else to print the output.

ELIF STATEMENTS:

Elif statements are the replacement of nested if-else statement.


DAY-20:

DIFFERENCE BETWEEN ELIF AND NESTED IF-ELSE

OBSERVATION.

In elif only one true block will generate output , but where in nested if-else all the block which are
true will generate output.

NESTED IF & IF-ELSE-

Conditional statements inside the conditional statements

If condition1:

If condition2:

Print(‘nested if block’)

Else:

Print(‘nested else block’)

Else:

Print(‘else block’)

ELIF:

If condition:

Print(‘if block’)

Elif condition:

Print(‘elif block’)

Else:

Print(‘else block’)
DAY-21:

CONTROLFLOW STATEMENT:

OBSERVATIONS:
PASS:

If we don’t have any code block in if statement or we don’t want to have any code block then we can
use pass keyword to skip the code block and avoid indentation error.

BREAK:

-break is used to stop a loop before it reaches a last iteration.

CONTINUE STATEMENT:

It is used to skip an iteration but the program run till the last iteration..

Skip execution of given iteration if continue statement is executed.

Skips the next lines in the current iteration.


DAY-22:

LOOP:

OBSERVATION:

LOOP:

Meaning of loop: running in a circular path/ repeated.

Loop gives the ability to run the code again and again.

Loop is used to execute a block of code multiple times in a sequence.

Loop allows us to reuse same code multiple times.

FOR LOOP:

When we want to run the repeatedly for n time, then we use for loop to run the code again again for
n time.

When we know number of repetitions / iterations(laps) then we use for loop

WHILE LOOPS:

Number of iterations are unknown

Loop is controlled by a condition.

After every iteration status of the condition is checked if the condition is true then only the next
iteration begins.
DAY-23:

NESTED LOOPS

OBSERVATIONS:

OUTER LOOP:

Outer loop is the 1st loop in the nested loop,

Runs=1

Iterations= range of the outer loop or len(collection)

INNER LOOP:

Inner loops is the loop inside the 1st loop

Runs=iterations of outer loop

Iterations= range of the inner loop or len(collection).


DAY-24:

LIST COMPREHENSION:

OBSERVATIONS:

Use to populate lists/create lists using other collections and for loop.

It a short cut or simple way to write for loop for small programs.

The result should only be a value and element not the reassignment.
DAY-25:

FUNCTIONS:

OBSERVATIONS:

FUNCTIONS:

-block of code which we can reuse wherever we want in the code.

-function of used to for code reusability, reducing duplication in the code.

-functions make the code as a modular such that the code usage will be effective.

BULIT-IN FUNCTIONS:

These built in functions are the functions which comes along with the python.

Print(),len(),s1.lower(),l1.append()

CUSTOM FUNCTIONS/USER DEFINED FUNCTIONS:

The custom functions are the functions that we need to create.


DAY-26:

HOW TO CREATE A FUNCTION

OBSERVATION:

HOW TO CREATE A FUNCTION

-identifiers in python are user defined functions.

-identifiers have rules to create their names.

-as function names are also identifiers similar to variable names, they follow same naming rules

**for using user defined function, it includes 2 steps

1.definning the function/ creation of function.

2.calling the function.


DAY-27:

ELEMENTS IN FUNCTION

OBSERVATION:

1.FUNCTION_NAME – it have some rules to define a function name.

2.FUNCTION PARAMETERS- the input that entered in the brackets of function, the same input we
have use in writing the mathematical expression or function block while defining the function.

3.FUNCTION_ARGUMENTS- values/variables passed as a input during function call.

4.FUNCTION BLOCK- the line following the indentation after the function definition.

5.FUNCTION RETURN- the variable/value returned by function to store them in another variable.
DAY-28:

POSITIONAL ARGUMENTS:

KEYWORD ARGUMENTS:

OBSERVATIONS:

POSITIONAL ARGUMENTS:

Values of parameters are dependent on positions of arguments.

KEYWORD ARGUMENTS:

Values of parameters are dependent on key-value pairs.

When we call the function, the function considers the order of arguments as order of parameters.

To avoid this we use keyword arguments.

Assigning the values(arguments) to the parameters(the variables used while defining the function)
DAY-29:

PROPERTIES OF FUNCTION:

OBSERVATIONS:

PROPERTIES OF FUNCTION:

1.Function always returns a value/None.

-if return statement is there then the particular value is been returned.

-if return statement is not there then None is returned.

2. Return statement not only returns/stores the value it is also used to stop the execution of the
function.

3.when we return multiple variables, we should use necessary variables to or single variable to store
the values that function is returning. Using less or more variables to store the returned value of the
function shows value error.

4.using single variable to store the return value make the output stored in the form of a tuple.

5.when we try to check the type of the function name that we used to create a function it shows that
the type is function.

6.variable,functions are identifiers.

7.Functions are treated as first-class data objects.

8.As function returns a value we treat them as a data objects.

9.As functions treated as data objects we can use them in another data types like list,tuple,set,etc.
DAY-30:

WAYS OF CALLING A PYTHON FILE:

OBSERVATION:

WAYS OF CALLING A PYTHON FILE:

There are 2 ways in which we can call/use a python file.

CASE-1: DIRECT CALL – python. file name. py-

Running file name.py in terminal

Code outside of main runs and inside of main also runs

When we do direct call of filename.py file ->then __name__variable takes values as __main__

__name__ =__main__ in direct call

CASE-2: MODULE CALL- import file name

Importing filename.py as a module in another file

Code outside of main runs but code inside of main didn’t run.

When we do module call of filename.py -> then __name__ variable takes value as module name/file
name.

__name__= filename in module call

CONDITION IN SCRIPT FILE:

If __name__=’__main__’:

Code

The condition will become True if the file is called directly.


DAY-31:

SPECIAL FUNCTIONS/HIGHER ORDER FUNCTIONS:


OBSERVATIONS:

LAMBDA FUNCTION:

It creates a function without a function name.

Nameless function.

It is used to create a one line function.

ZIP FUNCTION:

Clubs two or more iterables together.

MAP FUNCTION:

Applies a function on an iterable.

Returns an iterable of result.

The iterable returned by map function can be used only once.

FILTER FUNCTION:

It applies a condition on elements of an iterable/collection and then filters the elements based on
condition. The elements in the iterable/ collection will remains same value.

REDUCE FUNCTION:

Applies a function on elements in a collection- cumulatively

Reduce a collection into a single value


DAY-32:

EXCEPTION HANDLING:

OBSERVATIONS:

EXCEPTION HANDLING:

Exception is a type of error

There are 2 main categories of error-

1.Syntax error

Syntax error shows us the correctness of the script/written code

2.Runtime error(name error, type error, index error)

Run time error usually comes when code execution is happening.


DAY-33:

TRY-EXCEPT BLOCK

OBSERVATION:

TRY – EXCEPT BLOCKS:

Python would try to execute TRY block but if any error occur in try block then except block would
start running.

By using try and except block the code will run end to end even though there is some error in the
code(Run time error).

If any error occur in try block then except block will start executing. The line after the exception will
stop getting executed.
DAY-34:

FINALLY KEYWORD, RAISING EXCEPTIONS FORCEFULLY

OBSERVATION:

FINALLY KEYWORD:

Finally is keyword. The block code in finally keyword is always runs irrespective of the error.

RAISING EXCEPTIONS FORCEFULLY:

We can raise error/exception and stop the execution of the program.


DAY-35:

FILE HANDLING

OBSERVATION:

FILE HANDLING:

Creating files and storing data/information in it

When we restart the application all the data/information/variable will be lost to overcome this we
use file handling.

These files are created to store the information because the information that is been written the
code is not permanent.so, we use files to store the data/information. Stopping the execution of code,
close the program, etc led to deletion of the data.

CREATING FILE TO STORE INFORMATION:

Computer only understands binary format.

All files are stored in binary format in computer memory- ROM (Hard drives, SSD’s)

.txt , .jpg , .mp3 ,.mp4, .pdf in all these formats the data is been stored in binary format(combination
of 0 & 1’s)

1byte=8bits (combination of 8 0&1’s)

1024bytes=1kb
DAY-36:

OPEN FUNCTION

WRITE FORMAT

APPEND FORMAT

EXIST MODE(x):

READ MODE:

CLOSE

OBSERVATION:

OPEN FUNCTION:

Create a file object in which we can put the data and save the file.

OPEN keyword takes file path as input to generate a file.

WRITE FORMAT

W is the mode of the file w means write format. We put W to write or edit the file.

When file is opened in write mode, it creates a new empty file at same location.

Data stored in the previous run gets deleted.

APPEND FORMAT

a specifies the mode of the file

a means Append format

append format is used to add new lines to existing file without deleting previous file.

CLOSE:

Close keyword- closing the file – it’s needed such that once use of the file is done we can free its
memory from RAM.

EXIST MODE(x):

Exists mode is useful in creating a file.

If a file already exists at the given location then exist mode will not create a new file at the same
location it shows FileExistsError.

READ MODE:

Read mode is used to read all the data in the file in a single statement
DAY-37:

PROBLEM IN FILE HANDLING

OBSERVATION:

prices={'apple':100,'banana':40,'cherry':80,'watermelon':60}

kgs={}

p={}

total=0

for k in prices.keys():

kgs[k]=float(input(f'how many kgs of {k} you want?:))

file=open('bill.txt','w')

file.write('Bill - Mar29, 2024\n')

file.write('-------------------\n')

file.write('Item | Rate | Kgs | Amount\n')

for k in prices.keys():

p[k]=prices[k]*kgs[k]

file.write(f'k|{prices[k]}|{kgs[k]}|{p[k]}')

total+=p[k]

file.write(f'Total Cost={total}')

file.close()
Day-38:

CLASS AND OBJECTS

OBSERVATIONS:

CLASS:

Collection of objects having some similar properties.

Class acts as blueprint for all objects(basic structure/basic behaviour).

Blueprint shows all properties of any given objects.

Objects of classes have some variables and methods associated to them.

Bulit in classes- list, tuple, set, str, etc.

OBJECTS:

Objects is real world entity

Every object contains 2 major properties.

1.Attributes/Variables stores information in objects

2.FUNCTIONALITY- methods/functions- responsible for behaviour of object.


DAY-39:

INTRODUCTION OF OOPs(Object Oriented Programming):

OBSERVATION:

INTRODUCTION OF OOPs

Python is an object oriented programming

Almost all the things we see in python are objects and classes.

Programming which is based on objects and classes are known as OOPs

BENEFITS:

Uniformity of program/data types /functionality(almost all the functions of an object works similar to
other object in same class.)

Modularity in code(Some functions are predefined for the classes.)

Better code management for software/ application development.


DAY-40:

CLASS METHOD AND SELF KEYWORD:

OB SERVATION:

USER DEFINED CLASSES:

We can create a class in python using the keyword class followed by class name.

Class attributes and methods of the class are defined inside the indentation of the class keyword.

Self keyword is used as parameter while defining the class method.

This helps in making application modular, easy to maintain, user friendly.

CLASS METHOD AND SELF KEYWORD:

For every class method definition, self keyword must be the 1st parameter.

Class methods are local for given class. We cant use class methods until we create we create an
object

A class method can be called inside another class method as well.

Self keyword is used for referring class instance/object.

When we access object attributes/methods outside of class definition, we use object names.

But inside class definition we use self as a place holder / reference to class instance.
DAY-41:

CONSTRUCTOR ,STATIC VARIABLE, INSTANCE VARIABLES,

OBSERVATIONS:

CONSTRUCTOR

Constructor is used to create/ construct objects.

Used to store different/dynamic values in object’s attributes.

STATIC VARIABLE/CLASS VARIABLE:

Static variables are common values in the class. These static variables gets assigned by values before
defining the constructor.

INSTANCE VARIABLES:

Instance variable can be accessed by attributes/class variables.


DAY-42:

FUNCTION OVERLOADING AND FUNCTION OVERRIDING:

OBSERVATIONS:

FUNCTION OVERRIDING:

Re-Creating function with same name- causes function overriding.

Python always uses the latest definition.

FUNCTION OVERLOADING:

A function working on different parameters despite having same name.

Same function works differently on different types of inputs.

Overloading is not natively supported by the python.

But we can use if else statements to do it.


DAY-43:

TYPES OF METHODS

OBSERVATIONS:

TYPED OF METHODS:

-Instance methods

-Class methods

-Static methods.

INSTANCE METHODS:

In this case, Methods can be used only after creation of objects.

Instance method doesn’t work with class name.

CLASS METHOD:

Also works without creating an instance.

STATIC METHOD:

Instance/class

Works without self/cls keywords.


DAY-44:

PILLARS OF OPPs:

OBSERVATION:

1.INHERITANCE:

Having connection/dependency between multiple entities in an application.

Inheritance general meaning- Properties/qualities coming from generation to another generation.

Allows to reuse the code which provides code deduplication/modularity.

POLYMORPHISM:

Poly means many

Morphism means forms/behaciour

Polymorphism—

Same method having different behaviour in different situations.

ENCAPSULATION:

Access Modification(Public, private, protected).

By default all members of a class(Variables, Methods) are public.

Adding ‘__’ in the prefix make these members private

Adding ‘_’ in the prefix make these members protected.

ABSTRACTION:

Hiding complex information(from end user/anyone) and only showing necessary information is the
base of abstraction.

Abstraction is not mandatory that every application should have abstraction.

We use abstraction only in some cases where we want to have uniformity.

Whenever we create a class and its methods, attributes then user is unknown of internal complexity
of class.

This is a form of abstraction.


DAY-45:

INHERITANCE

OBSERVATION:

1.Basic Inheritance

Child has all the properties of parent but doesn’t have any of its own properties.

Child is exactly copy of parent.

Here child student is inheriting constructor and info method from parent Person.

2.Single Inheritance

We can override the functions, methods but we can still reuse them inside the child class.

So that the relation between the child and parent class is been maintained and the child will also
exhibit some new properties.Some modified behaviour of the methods.

3.multi-Level Inheritance / Hierarchical Inheritance

A child class is parent of another child class.

Here, a child class(B) is been parent to another class(C) and the child’s child class(C) will have both
the parent class properties (A),child class properties (B)and its own properties(C).

4.Multiple Inheritance

A child class has more than one parent class.

Having a multiple parent classes for a single child class.

Child class will inherit properties of all parent classes.

5.Hybrid Inheritance

In hybrid inheritance, there are multiple parents for same child class / some parent classes will
become child classes.
DAY-46:

POLYMORPHISM

OBSERVATION:

BENEFITS OF POLYMORPHISM:

Uniformity in multiple entities inside a software application / product code.

1.POLYMORPHISM WITH METHOD OVERRIDING

2.POLYMORPHISM WITH METHOD OVERLOADING

3. POLYMORPHISM WITHOUT METHOD OVERRIDING / METHOD OVERLOADING:


DAY-47:

ENCAPSULATION

Observation:

PUBLIC VARIABLES/MEMBER:

Public variables are the variables/attributes that can be accessed outside of class.

We can change values of public attributes.

PRIVATE VARIABLE/MEMBER:

To create a private variable we need to add 2’_’(__) before the variable.

We can not access these variables outside of the class.

We can nit even modify the values of private member.

PROTECTED MEMBERS:

Protected members can not be accessed outside of the parent class.

But can be accessed inside parents class and its child class.

In python, the access/modify the protected member is not very strict.


DAY-48:

ABSTRACTION

OBSERVATION:

BASE CLASS ABSTRACTION

Used to maintain uniformity of application/module

In order to maintain uniformity of applications like this- we create a Abstract Base Class.

This ABC is used as a blueprint for all the classes(for which we need uniform behaviour) inside an

application.

To use ABC we need to import it from a module called(abc)

Abstract method is also to be imported from the module abc. It is a decorator.


DAY-49:

NAME MANGLING, GETTER AND SETTER METHODS

Observation:

GETTER AND SETTER METHODS:

Using Getter method we can get access to class variables/methods.

Using Setter method we can modify class variables/methods.

NAME MANGLING:

We can access/modify the private members using the class name

Using Name mangling we can also access and modify the ‘Private’ attributes outside of the class.

Python programming language has ’freedom for developers’ as its basic pillar.

Developers should be able to make all type of changes in the code that they use.

Which all attributes/members should not be access outside of the class directly.

If we add more than one ’_’ in suffix, then name mangling rule changes for that attribute.
DAY-50:

RAISING A CUSTOM EXCEPTION:

OBSERVATION:

Class Error(Exception):

#Here Exception is passed as a parent class. Exception is the inbuilt class that python has.

Exception class includes all types of Error.

Class Error(Exception):

Pass

Class NegativeValueError(Error):

Pass

Here basic Inheritance is been followed by both Error and Negative Value Error.

This is how we created a custom exception.

You might also like