Professional Documents
Culture Documents
and Modules
Prepared By Group 11:
Wyndel S. Albos
Apple Kimberly Calvario
Rieza Jane Naisa
Ma. Angelica Norial
Objectives:
By the end of this presentation students will be able to:
● Instead, version control lets developers safely work through branching and merging.
● With branching, a developer duplicates part of the source code (called the repository). The
developer can then safely make changes to that part of the code without affecting the rest of the
project.
● Then, once the developer gets his or her part of the code working properly, he or she can merge that
code back into the main source code to make it official.
● All these changes are then tracked and can be reverted if need be.
What is Git?
What is it used for? And What is Git in GitHub?
The “Git” in GitHub
• Git is a specific open-source version control system created by Linus Torvalds in
2005.
• Specifically, Git is a distributed version control system, which means that the entire
codebase and history is available on every developer’s computer, which allows for
easy branching and merging.
• So, Git is a version control system, but what does that mean? When developers create
something (an app, for example), they make constant changes to the code, releasing
new versions up to and after the first official (non-beta) release.
Demonstration
I will show you the Demonstration of Git and
GitHub and how it will work.
02
Functions
2nd Topic
Functions
What is Function? Defining/Creating Calling Function
A function is a block of a function Use the function name followed by
code which only runs
parenthesis.
when it is called. • “def” keyword is use.
Example:
Variable Scope
● Variables in python have a scope which determines where it can be
accessed.
Example:
Local Vs Global
LOCAL GLOBAL
Defined inside a function. Defined outside a function.
Can only be accessed inside the function Can be accessed throughout the program
in which they are declared. and inside every function.
Example:
Global Gotcha
Examples:
Parameters
● Variable listed inside the parentheses in the function definition.
Example:
Parameters
● Positional - arguments for all positional parameters must be provided
in the order they are listed
● Optional - arguments can be provided positionally and are not
required
Example:
Documentation
● It’s often helpful to leave information in your
code about what you were thinking when you
wrote it.
● This can help reduce the number of WTF(
“Works that Frustrate”)’s per minute in reading
it later.
There are two approaches to this:
Comments Docstrings
Go inline in the body of Strings literals that appear right
code to explain reasoning after the definition of a function
A Docstring should:
● Be a complete sentence in the form of a command describing
what the function does.
● Have a useful single line.
o If more description is needed, make the first line a complete
sentence and add more lines below for enhancement.
● Be enclosed with triple-quotes.
Recursion
A process in which a function calls itself.
Example:
03
Boolean
3rd Topic
What is Boolean?
• Python Boolean type is one of the built-in data
types provided by Python, which represents one
of the two values i.e. True or False. Generally, it
is used to represent the truth values of the
expressions.
Boolean Values
• In programming you often need to know if an
expression is True or False.
What is True?
Everything Else
Syntax:
bool([x]) Example: Python bool() method
Example: Python
bool() method
Integer and Floats as Booleans
Numbers can be used as
bool values by using Python’s
built-in bool() method.
Boolean Operators
• Boolean Operations are simple arithmetic of True and False
values. These values can be manipulated by the use of
Boolean operators which include AND, Or, and NOT.
Common Boolean operations are –
• Or
• And
• Not
• == (equivalent)
• != (not equivalent)
• In the above example, we have used Python Boolean with if statement and
OR operator that check if a is greater than b or b is smaller than c and it
returns True if any of the condition is True (b<c in the above example).
Boolean Operators
• The Boolean AND operator returns False if any one of the
inputs is False else returns True.
• Example: in Operator
04
Modules
4th Topic
Contents
1. Code structure
2. Modules and Packages
3. Importing a module
4. Advantages of Modules
5. Listing all the contents of the module
6. Built-in modules
Code Structure You can put a one-liner after the colon:
name.another_name
name in a module
module in a package
attribute of an object
method of an object
Module
- Is simply a namespace.
- It might be a single file, or it could be a collection
of files that define a shared API.
- Files you write that end in .py as modules.
- A module allows you to logically organize your
Python code. Grouping related code into a
module makes the code easier to understand and
use.
- A module is a Python object with arbitrarily named
attributes that you can bind and reference.
- Simply, a module is a file consisting of Python
code.
- A module can define functions, classes and
variables. A module can also include runnable
code.
How to create a module?
To create module, simply save your codes in a file with
the file extension py.
Namespace
Importing
• The process by which Python code in one
module is made available to Python code in
another module.
• Python's "import" loads a Python module into its
own namespace, so that you have to add the
module name followed by a dot in front of
references to any names from the imported
module that you refer to:
-To access the codes from the modules -To create an alias for the module:
from modulename import this, that from modulename import this as that
Advantages of Modules
Reusability
Working with modules makes the code reusable.
Simplicity
The module focuses on a small proportion of the
problem, rather than focusing on the entire problem.
Scoping
A separate namespace is defined by a module that
helps to avoid collisions between identifiers.
Package
- Is a module with other modules in it.
- On a filesystem, this is represented as a directory
that contains one or more .py files, one of
which must be called __init__.py.
Example of a Python package:
What is the purpose of
__init__.py?
- It helps the python to determine whether
the directory is a python package.
You!
Flaticon, infographics & images by Freepik