Understanding Python - Functions, Modules,

Published  . 0 views
↓ Download
Understanding Python - Functions, Modules,
1 / 1
Understanding Python - Functions, Modules, - slide 1 of 10 Understanding Python - Functions, Modules, - slide 2 of 10 Understanding Python - Functions, Modules, - slide 3 of 10 Understanding Python - Functions, Modules, - slide 4 of 10 Understanding Python - Functions, Modules, - slide 5 of 10 Understanding Python - Functions, Modules, - slide 6 of 10 Understanding Python - Functions, Modules, - slide 7 of 10 Understanding Python - Functions, Modules, - slide 8 of 10 Understanding Python - Functions, Modules, - slide 9 of 10 Understanding Python - Functions, Modules, - slide 10 of 10
Description: Understanding Python - Functions, Modules, Packages, and Libraries A Beginners Guide to Python Programming Introduction Python is a powerful, versatile, and easy-to-learn programming language. Used in engineering, geosciences, data

Related Topics

Download Presentation

"Understanding Python - Functions, Modules," is the property of its rightful owner. Permission is granted to download and print the materials on this website for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.

Presentation Transcript

slide1. Understanding Python - Functions, Modules, Packages, and Libraries A Beginner's Guide to Python Programming<br>
slide2. Introduction Python is a powerful, versatile, and easy-to-learn programming language.
Used in engineering, geosciences, data analysis, machine learning, and automation.<br>
slide3. Functions - The Chefs of Python Think of a function as a chef in a restaurant. The chef takes ingredients (inputs), follows a recipe (code inside function), and serves a dish (output).
Definition: A function is a reusable block of code that performs a specific task. Example:
def greet(name):
     return f"Hello, {name}!"
 print(greet("Zoubida"))<br>
slide4. Modules - The Recipe Book A module is like a recipe book—it's a collection of functions that can be reused without rewriting them.
Definition: A module is a Python file that contains functions and variables. Example:
import math
print(math.sqrt(16))<br>
slide5. Creating Your Own Module There are a set of modules that are built in python. If you need to use them you just have to import them to your code.
Now if the function you need does not exist in any of these modules, you can install one that are created by other developers or create your own module.
You will have to create a .py file in which all the functions that you want are defined.
Once you import it you can then use the functions in any code you write Example:
# my_module.py
 def add(a, b):
     return a + b
import my_module
print(my_module.add(3, 5))<br>
slide6. Packages - The Kitchen Cabinet A package is like a kitchen cabinet that stores multiple recipe books (modules).
Definition: A package is a directory containing multiple modules along with a special __init__.py file.
NumPy is a package containing multiple mathematical modules. Example:
import numpy as np
A = np.array([[2, 5], [6, 9]])
det_A = np.linalg.det(A)
print("Determinant:", det_A)<br>
slide7. Libraries - The Supermarket A library is like a supermarket—it contains many packages for different purposes.
Definition: A library is a collection of modules and packages designed to perform specific tasks.
Examples:
NumPy for numerical computations
Pandas for data manipulation
Matplotlib for plotting
OpenCV for image processing<br>
slide8. Resources to Learn Python Official Docs: https://docs.python.org/
The legend of python: https://www.codedex.io/python
Learning python : https://www.learnpython.org/
Machine learning with python: https://geostatsguy.github.io/MachineLearningDemos_Book/intro.html
And of course YouTube (You will definitely find someone who explains everything in the right way for your learning objectives)<br>
slide9. Advice for Learning Python Practice regularly - Write code daily to reinforce learning.
Start with small projects - Build a calculator, a data analysis script, etc.
Read others' code - Learn best practices and efficient coding techniques.
Join Python communities - Engage with other learners and professionals.<br>
slide10. Thank you! Email: nemer.zoubida@univ-ouargla.dz
Address: Faculty of Hydrocarbons, Renewable Energies, Earth and Universe Sciences- Department of Earth and Universe Sciences.
You can scan the QR code to get this presentation and the Notebook.<br>