[go: up one dir, main page]

0% found this document useful (0 votes)
34 views6 pages

Assi 5 Oop Usman 16309

This assignment submission includes 5 tasks related to object oriented programming and Python modules. It provides sample inputs and outputs for each task. Task 3 includes a table describing the differences between public, protected, and private access modifiers. Task 5 defines modules, packages, import statements, and the differences between absolute and relative imports in Python.
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)
34 views6 pages

Assi 5 Oop Usman 16309

This assignment submission includes 5 tasks related to object oriented programming and Python modules. It provides sample inputs and outputs for each task. Task 3 includes a table describing the differences between public, protected, and private access modifiers. Task 5 defines modules, packages, import statements, and the differences between absolute and relative imports in Python.
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/ 6

Assignment # ( 05 )

Subject:- Object Oriented Programming

Section:- CC

Submitted to:- Sir Saqib Shahid Rahim

Submitted by:- Muhammad Usman 16309

Date:- 25/ 04 / 2020


Task 1:

Input

Output:
Task 2:

Input

Output
Task 3:

REQUIRED TABLE
Public Protected Private

The data members of the The data members of a The data members of a
class public can be class protected are only class private are
accessed from anywhere accessible to a class accessible within the class
in the program. derived from it only

For public Nothing add adding a single adding a double


before data member of underscore ‘_’ symbol underscore ‘__’ symbol
class before the data member before the data member
of that class. of that class

private access modifier is


the most secure access
modifier

Outsider members can Outsider members Outsider members


access those variables cannot access those cannot access those
variables variables.
Task 4:

Reason:
is one of the fundamental aspects of Object Oriented Programming. It allows programmers
better control of how data flows in their programs, and it protects that data.

Input

Output
Task 5:
i. Modules and Packages
• A package is a collection of Python modules
• A module is a single Python file

ii. Regular Packages and Namespace Packages


Regular packages

• are self-contained: all parts live in the same directory hierarchy.


Namespace packages
• have no __file__ attribute. Namespace packages' __path__
attribute is a read-only iterable of strings, which is automatically
updated when the parent path is modified. Namespace packages
have no __init__.py module

iii. Import and from import


• Import we use to import function of our program
• While from import is used to take program from folder of that file

iv. Absolute import and Relative import


• An absolute import uses the full path (starting from the project's
root folder) to the desired module to import.
• A relative import uses the relative path to desired module to import

You might also like