0% found this document useful (0 votes)
79 views16 pages

Pytest Day-1 PDF

This document provides an overview of additional Python topics covered on Day 1, including modules, object-oriented programming concepts like classes, methods, inheritance, and more. Key points include that modules allow organizing Python code into reusable files, classes contain variables and methods to define objects, the self parameter refers to the instance, and inheritance allows classes to inherit attributes and behaviors from parent classes.

Uploaded by

Ravindra S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views16 pages

Pytest Day-1 PDF

This document provides an overview of additional Python topics covered on Day 1, including modules, object-oriented programming concepts like classes, methods, inheritance, and more. Key points include that modules allow organizing Python code into reusable files, classes contain variables and methods to define objects, the self parameter refers to the instance, and inheritance allows classes to inherit attributes and behaviors from parent classes.

Uploaded by

Ravindra S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Python Additional

Topics
Day-1 : Module & OOPS Concepts

Meganadha Reddy K
Sr. Manager, L&D, Cigniti
Module
• A module is file consisting of Python Code
Maths.py
Object Oriented Programming - Introduction

• A class normally contains variables and methods


• Sometimes we also refer class as,
Group of attributes and procedures
Simple Class [Example-1]
Simple Class [Example-2]
self (&) other parameters
Self parameters :
We don’t have to mention all parameters of the class in methods, just self is
enough.
self ➔ refers to instance and can use it go get instance variables.
Other parameters:
We need to mention them as parameters for the method.
Private variables
• We DO NOT have keywords like public, private or protected in Python.
• By default the variables / methods are public
Methods accessing – private variables
Constructor in Python (1 of 2)

__init__(self)

__init__(self, <<parameters>>)
Constructor in Python (2 of 2)
Destructor in Python (1 of 2)
• Destructor is used to free up the memory if the object is no longer in use.
• This is termed as Garbage Collection

__del__(self)
Destructor in Python (2 of 2)
isinstance(obj, class_name)
Statements – In Class [YES Allowed]
• In PYTHON, we can write statements directly inside class.
• This is not allowed in Java or C# languages
Inheritance and Types

A A A B

B
B C
Single Inheritance
C Multiple Inheritance

Multi Level Inheritance


Inheritance - Example

Without Inheritance With Inheritance

You might also like