SlideShare une entreprise Scribd logo
1  sur  30
Télécharger pour lire hors ligne
First Steps into Python Programming
Facilitator: Agbo Dozie
This May
Come to
Mind…
when
you hear
Python
But
its
more
like
this…
Table of Content
1
2
3
4
5
6
7
8
Python. Installation. Practical Uses
Why Python?
Variables, Datatypes (Strings,
Int, Float, List, Tuples, Bool, and
Dictionaries) & Formatting
Functions & Recursions in Python
Arithmetic Operators, Comparators,
Loops, & Conditionals
File Handling in Python
Modules in Python
Project & Setup Github
1
Python,
Installation &
Practical Uses
| Python. IDEs. Installing Python
What is Python?
of significant whitespace, as well as the DRY (Don’t Repeat Yourself) principle.
Wikipedia (Modified)
Installing Python is generally easy, and nowadays many Linux and UNIX distributions include a
recent Python. Even some Windows computers (notably those from HP) now come with
Python already installed. To check if you have Python on your computer, just open your
command prompt and type “Python”. You would see the result below, otherwise you do not
have Python installed.
In order to download Python however, visit the official Python website
https://www.python.org/downloads/ and download the latest version. During installation,
watch out and ensure to check the box labeled “Add Python to PATH”.
Installing an IDE
Installing Python
IDEs are the environment in which we would write Python codes. Python comes
with its default IDE called IDLE, which like the acronym IDE also stands for
“Integrated Development Environment”. Below are some of the most common
IDEs. From VSCode to Atom Editor to PyCharm, and to the very lightweight Sublime
Text.
Python is an interpreted, high-level, general-purpose
programming language. Created by Guido van Rossum
and first released in 1991, Python's design philosophy
emphasizes code readability with its notable use
| Practical Uses of Python
Web Development
Python can be used to make web-
applications at a rapid rate using
frameworks, such as Flask and Django.
Game Development
There are libraries such as PySoy and
PyGame which is a 3D game engine
supporting Python 3.
Machine Learning & AI
Machine Learning and Artificial
Intelligence are the talks of the town as
they yield the most promising careers for
the future.
Data Science & Data
Visualizations
Libraries such as Pandas, NumPy help
you in extracting information. We can
also use libraries like Matplotlib and
Seaborn for visualizations.
Desktop GUI
Python can be used to program desktop
applications. It provides the Tkinter
library that can be used to develop user
interfaces.
Webscraping Applications
Python can be used to pull a large
amount of data from websites which can
then be helpful in various real-world
processes.
Business Applications
Business Applications cover domains
such as e-commerce, ERP and many
more.
Audio & Video Apps
Python can be used to develop Video
and audio applications such as TimPlayer
and Cplay. These apps often provide
better stability and performance
compared to other media players.
CAD Applications
Computer-Aided Designs apps can be
complicated, but Python makes this
simple. Example is Fandango.
Embedded Apps
Python is based on C which means that it
can be used to create Embedded C
software for embedded applications.
2
Why Python?
| Why Python?
▪ Python is easy to learn
▪ It has a vast community of users
▪ There is plethora of ‘fancy’ career paths for
Python developers
▪ Python can be used for Web development
▪ Python is useful in AI and Machine Learning
▪ Python has millions of modules and frameworks
▪ There has been a lot of adoption and shifting by
Startups and Corporates to Python
| Why Python?
try:
aFile = open('anyOldFile.txt')
myString = aFile.readline()
print('File contents are: ')
print(myString)
except IOError as e:
print "I/O error({0}): {1}".format(e.errno, e.strerror)
#include <iostream>
#include <exception>
using namespace std;
int main () {
int* myarray = NULL;
if (myarray) {
cout << "Not NULL" << endl;
} else {
cout << "Is NULL" << endl;
}
try
{
int* myarray = new int[1000000000];
}
catch (exception& e)
{
cout << "Standard exception: " << e.what() << endl;
if (myarray) {
cout << "Not NULL" << endl;
} else {
cout << "Is NULL" << endl;
}
}
if(myarray) {
cout << "Deleting myarray" << endl;
delete [] myarray;
}
cout << "Returning" << endl;
return 0;
}
Python
C++
3
Variables, Datatypes
(Strings, Int, Float,
List, Tuples, Bool, and
Dictionaries) &
Formatting
| Variables
Variables are containers for storing data values. Unlike other programming languages, Python has no command for declaring a
variable. A variable is created the moment you first assign a value to it.
▪ A variable name must start with a letter or the underscore character
▪ A variable name cannot start with a number
▪ A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
▪ Variable names are case-sensitive (age, Age and AGE are three different variables)
RULES for Naming Variables
| Datatypes
Variables can store data of different types, and different
types can do different things.
Python has the following data types built-in by default, in
these categories:
Text Type: str
Numeric Types: int , float, complex
Sequence Types: list, tuple, range
Mapping Type: dict
Set Types: set, frozenset
Boolean Type: bool
Binary Types: bytes, bytearray, memoryview
| Formatting
String Concatenation
String Methods
String Formatting
There are other string methods
from len() to upper(), to lower().
In fact, you can use the dir(string)
command to get the methods
associated to strings.
There are other string formatting
techniques as well. There’s the %s
method as well as the direct
concatenation approach.
4
Arithmetic Operators,
Comparators, Loops,
& Conditionals
| Arithmetic Operators
Arithmetic Operators
Comparison (Relational) Operators
Assignment Operators
Logical Operators
Bitwise Operators
Membership Operators
Identity Operators
Addition
Subtraction
Multiplication
Division
Modulus
Exponent
Floor Division
==
!=
<>
>
<
>=
<=
=
+=
-=
*=
/=
%=
**=
//=
in
not in
Logical AND
Logical OR
Logical NOT
is
is not
| Loops
Python has two primitive loop commands:
• while loops
• for loops
A loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string). This is less like
the for keyword in other programming languages, and works more like an iterator method as found in other object-orientated
programming languages.
With the for loop we can execute a set of statements, once for each item in a list, tuple, set etc.
for
for
for
With the while loop we can execute a set of statements as long as a condition is true.while
| Conditionals
Python conditionals are used to test if certain conditions or expressions check out. For example, the popular litmus tests of
chemistry. In the test, the paper turns red when the paper is dipped in an acid and blue when dipped in a basic solution. Similarly,
in conditionals, we use the if and else keywords for “action” and “reaction” respectively.if else
You must have noticed the elif keyword; it is not mandatory; you only use it if you have more conditions to test. In other words,
your if/else block would work fine without it.
elif
Read up: Nested Ifs.
5
Functions &
Recursions in
Python
| Functions in Python
A function is a block of code which only runs when it is called. You can pass data, known as parameters, into a function. A
function can return data as a result.
In Python a function is defined using the def keyword:
To let a function return a value, use the return keyword.
| Functions in Python Contd.
Example:
By default, a function must be called with the correct number of arguments. Meaning that if your function expects 2 arguments,
you have to call the function with 2 arguments, not more, and not less.
Give a function all it wants and it would answer your call, otherwise, it spits out errors.
| Recursions
▪ Python also accepts function recursion, which means a defined function can call itself.
▪ Recursion is a common mathematical and programming concept. It means that a function calls
itself. This has the benefit of meaning that you can loop through data to reach a result.
▪ >> The developer should be very careful with recursion as it can be quite easy to slip into writing
a function which never terminates, or one that uses excess amounts of memory or processor
power. However, when written correctly recursion can be a very efficient and mathematically-
elegant approach to programming. We consider and example below:
What does the recursion below do?
6
File Handling
in Python
| File Handling in Python
File handling is an important part of any web application. Python has several functions for creating, reading, updating, and
deleting files.
We would consider the 4 operations below, i.e, CRUD.
The key function for working with files in Python is the open() function. The open() function takes two parameters;
filename, and mode. Let’s see the syntax below:
Open
To open the file, use the built-in open() function. The open() function returns a file object, which has a read() method for
reading the content of the file:
Read
Note: You can return one line by using the readline() method. Also it is always good practice to close a file when you
are done using it. To do this, use the close method, i.e f.close().
| File Handling in Python Contd.
To write to an existing file, you must add a parameter to the open() function:
"a" - Append - will append to the end of the file | "w" - Write - will overwrite any existing content
Note that new files would be created if they do not already exist.
Write
To delete a file, you must import the OS module, and run its os.remove() function:Delete
7
Modules in
Python
| Modules in Python
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. Modules are all about reusability. Take for example the code below:
Save this code in a file named mymodule.py. To use the module, we use the import statement.
You could wish to import only a function or variable from your module. That wish can be granted without a genie, easily.
You see? Just use from and import!
8
Project &
Setup Github
| Project & Setup Github
Also called “The New Resume”, GitHub is a git repository hosting service.
Simply, Github helps you do version control while coding. Most employer’s
now ask to see your GitHub repository when applying for developer roles.
Setting Up GitHub
▪ Create a GitHub Account
▪ Download and install git from https://git-scm.com/downloads. Choose
your laptop’s specification (OS)
▪ Login in GitHub Username and Password in local machine and start
We would be more exhaustive on this in our demo session. Cheers!
Project:
i. An iPython Notebook has been attached and shared. Study the items in it and work the problem underneath.
ii. Write a recursion for printing a list of first n Fibonacci numbers.
committing changes and pushing files to GitHub!
Thank you for
Listening…
Any Questions?
Contact me on: agbodozie660@gmail.com

Contenu connexe

Tendances

AI and ML Series - Introduction to Generative AI and LLMs - Session 1
AI and ML Series - Introduction to Generative AI and LLMs - Session 1AI and ML Series - Introduction to Generative AI and LLMs - Session 1
AI and ML Series - Introduction to Generative AI and LLMs - Session 1DianaGray10
 
Building, Evaluating, and Optimizing your RAG App for Production
Building, Evaluating, and Optimizing your RAG App for ProductionBuilding, Evaluating, and Optimizing your RAG App for Production
Building, Evaluating, and Optimizing your RAG App for ProductionSri Ambati
 
Landscape of AI/ML in 2023
Landscape of AI/ML in 2023Landscape of AI/ML in 2023
Landscape of AI/ML in 2023HyunJoon Jung
 
Machine Learning presentation.
Machine Learning presentation.Machine Learning presentation.
Machine Learning presentation.butest
 
"Large-Scale Deep Learning for Building Intelligent Computer Systems," a Keyn...
"Large-Scale Deep Learning for Building Intelligent Computer Systems," a Keyn..."Large-Scale Deep Learning for Building Intelligent Computer Systems," a Keyn...
"Large-Scale Deep Learning for Building Intelligent Computer Systems," a Keyn...Edge AI and Vision Alliance
 
Global Azure Bootcamp Pune 2023 - Lead the AI era with Microsoft Azure.pdf
Global Azure Bootcamp Pune 2023 -  Lead the AI era with Microsoft Azure.pdfGlobal Azure Bootcamp Pune 2023 -  Lead the AI era with Microsoft Azure.pdf
Global Azure Bootcamp Pune 2023 - Lead the AI era with Microsoft Azure.pdfAroh Shukla
 
Build an LLM-powered application using LangChain.pdf
Build an LLM-powered application using LangChain.pdfBuild an LLM-powered application using LangChain.pdf
Build an LLM-powered application using LangChain.pdfAnastasiaSteele10
 
How do OpenAI GPT Models Work - Misconceptions and Tips for Developers
How do OpenAI GPT Models Work - Misconceptions and Tips for DevelopersHow do OpenAI GPT Models Work - Misconceptions and Tips for Developers
How do OpenAI GPT Models Work - Misconceptions and Tips for DevelopersIvo Andreev
 
Generative AI and ChatGPT - Scope of AI and advance Generative AI
Generative AI and ChatGPT - Scope of AI and advance Generative AIGenerative AI and ChatGPT - Scope of AI and advance Generative AI
Generative AI and ChatGPT - Scope of AI and advance Generative AIKumaresan K
 
AI Infra Day | The Generative AI Market And Intel AI Strategy and Product Up...
AI Infra Day | The Generative AI Market  And Intel AI Strategy and Product Up...AI Infra Day | The Generative AI Market  And Intel AI Strategy and Product Up...
AI Infra Day | The Generative AI Market And Intel AI Strategy and Product Up...Alluxio, Inc.
 
Prompt Engineering - an Art, a Science, or your next Job Title?
Prompt Engineering - an Art, a Science, or your next Job Title?Prompt Engineering - an Art, a Science, or your next Job Title?
Prompt Engineering - an Art, a Science, or your next Job Title?Maxim Salnikov
 
Word Embeddings, why the hype ?
Word Embeddings, why the hype ? Word Embeddings, why the hype ?
Word Embeddings, why the hype ? Hady Elsahar
 
Deep Learning Tutorial | Deep Learning Tutorial For Beginners | What Is Deep ...
Deep Learning Tutorial | Deep Learning Tutorial For Beginners | What Is Deep ...Deep Learning Tutorial | Deep Learning Tutorial For Beginners | What Is Deep ...
Deep Learning Tutorial | Deep Learning Tutorial For Beginners | What Is Deep ...Simplilearn
 
Data Analysis and Visualization using Python
Data Analysis and Visualization using PythonData Analysis and Visualization using Python
Data Analysis and Visualization using PythonChariza Pladin
 
AI and ML Series - Leveraging Generative AI and LLMs Using the UiPath Platfor...
AI and ML Series - Leveraging Generative AI and LLMs Using the UiPath Platfor...AI and ML Series - Leveraging Generative AI and LLMs Using the UiPath Platfor...
AI and ML Series - Leveraging Generative AI and LLMs Using the UiPath Platfor...DianaGray10
 
Discover AI with Microsoft Azure
Discover AI with Microsoft AzureDiscover AI with Microsoft Azure
Discover AI with Microsoft AzureJürgen Ambrosi
 
Machine Learning and AI
Machine Learning and AIMachine Learning and AI
Machine Learning and AIJames Serra
 
Generative AI in Healthcare Market.pptx
Generative AI in Healthcare Market.pptxGenerative AI in Healthcare Market.pptx
Generative AI in Healthcare Market.pptxGayatriGadhave1
 

Tendances (20)

AI and ML Series - Introduction to Generative AI and LLMs - Session 1
AI and ML Series - Introduction to Generative AI and LLMs - Session 1AI and ML Series - Introduction to Generative AI and LLMs - Session 1
AI and ML Series - Introduction to Generative AI and LLMs - Session 1
 
Building, Evaluating, and Optimizing your RAG App for Production
Building, Evaluating, and Optimizing your RAG App for ProductionBuilding, Evaluating, and Optimizing your RAG App for Production
Building, Evaluating, and Optimizing your RAG App for Production
 
Landscape of AI/ML in 2023
Landscape of AI/ML in 2023Landscape of AI/ML in 2023
Landscape of AI/ML in 2023
 
Serving ML easily with FastAPI
Serving ML easily with FastAPIServing ML easily with FastAPI
Serving ML easily with FastAPI
 
Prompt Engineering
Prompt EngineeringPrompt Engineering
Prompt Engineering
 
Machine Learning presentation.
Machine Learning presentation.Machine Learning presentation.
Machine Learning presentation.
 
"Large-Scale Deep Learning for Building Intelligent Computer Systems," a Keyn...
"Large-Scale Deep Learning for Building Intelligent Computer Systems," a Keyn..."Large-Scale Deep Learning for Building Intelligent Computer Systems," a Keyn...
"Large-Scale Deep Learning for Building Intelligent Computer Systems," a Keyn...
 
Global Azure Bootcamp Pune 2023 - Lead the AI era with Microsoft Azure.pdf
Global Azure Bootcamp Pune 2023 -  Lead the AI era with Microsoft Azure.pdfGlobal Azure Bootcamp Pune 2023 -  Lead the AI era with Microsoft Azure.pdf
Global Azure Bootcamp Pune 2023 - Lead the AI era with Microsoft Azure.pdf
 
Build an LLM-powered application using LangChain.pdf
Build an LLM-powered application using LangChain.pdfBuild an LLM-powered application using LangChain.pdf
Build an LLM-powered application using LangChain.pdf
 
How do OpenAI GPT Models Work - Misconceptions and Tips for Developers
How do OpenAI GPT Models Work - Misconceptions and Tips for DevelopersHow do OpenAI GPT Models Work - Misconceptions and Tips for Developers
How do OpenAI GPT Models Work - Misconceptions and Tips for Developers
 
Generative AI and ChatGPT - Scope of AI and advance Generative AI
Generative AI and ChatGPT - Scope of AI and advance Generative AIGenerative AI and ChatGPT - Scope of AI and advance Generative AI
Generative AI and ChatGPT - Scope of AI and advance Generative AI
 
AI Infra Day | The Generative AI Market And Intel AI Strategy and Product Up...
AI Infra Day | The Generative AI Market  And Intel AI Strategy and Product Up...AI Infra Day | The Generative AI Market  And Intel AI Strategy and Product Up...
AI Infra Day | The Generative AI Market And Intel AI Strategy and Product Up...
 
Prompt Engineering - an Art, a Science, or your next Job Title?
Prompt Engineering - an Art, a Science, or your next Job Title?Prompt Engineering - an Art, a Science, or your next Job Title?
Prompt Engineering - an Art, a Science, or your next Job Title?
 
Word Embeddings, why the hype ?
Word Embeddings, why the hype ? Word Embeddings, why the hype ?
Word Embeddings, why the hype ?
 
Deep Learning Tutorial | Deep Learning Tutorial For Beginners | What Is Deep ...
Deep Learning Tutorial | Deep Learning Tutorial For Beginners | What Is Deep ...Deep Learning Tutorial | Deep Learning Tutorial For Beginners | What Is Deep ...
Deep Learning Tutorial | Deep Learning Tutorial For Beginners | What Is Deep ...
 
Data Analysis and Visualization using Python
Data Analysis and Visualization using PythonData Analysis and Visualization using Python
Data Analysis and Visualization using Python
 
AI and ML Series - Leveraging Generative AI and LLMs Using the UiPath Platfor...
AI and ML Series - Leveraging Generative AI and LLMs Using the UiPath Platfor...AI and ML Series - Leveraging Generative AI and LLMs Using the UiPath Platfor...
AI and ML Series - Leveraging Generative AI and LLMs Using the UiPath Platfor...
 
Discover AI with Microsoft Azure
Discover AI with Microsoft AzureDiscover AI with Microsoft Azure
Discover AI with Microsoft Azure
 
Machine Learning and AI
Machine Learning and AIMachine Learning and AI
Machine Learning and AI
 
Generative AI in Healthcare Market.pptx
Generative AI in Healthcare Market.pptxGenerative AI in Healthcare Market.pptx
Generative AI in Healthcare Market.pptx
 

Similaire à First Steps in Python Programming

Similaire à First Steps in Python Programming (20)

Python Interview Questions For Experienced
Python Interview Questions For ExperiencedPython Interview Questions For Experienced
Python Interview Questions For Experienced
 
Python fundamentals
Python fundamentalsPython fundamentals
Python fundamentals
 
Core python programming tutorial
Core python programming tutorialCore python programming tutorial
Core python programming tutorial
 
INTERNSHIP REPORT.docx
 INTERNSHIP REPORT.docx INTERNSHIP REPORT.docx
INTERNSHIP REPORT.docx
 
Python Course.docx
Python Course.docxPython Course.docx
Python Course.docx
 
Intro to python
Intro to pythonIntro to python
Intro to python
 
Introduction of Python
Introduction of PythonIntroduction of Python
Introduction of Python
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Python ppt
Python pptPython ppt
Python ppt
 
PYTHON PPT.pptx
PYTHON PPT.pptxPYTHON PPT.pptx
PYTHON PPT.pptx
 
Python (3).pdf
Python (3).pdfPython (3).pdf
Python (3).pdf
 
Python programming
Python programmingPython programming
Python programming
 
pythontraining-201jn026043638.pptx
pythontraining-201jn026043638.pptxpythontraining-201jn026043638.pptx
pythontraining-201jn026043638.pptx
 
Python Programming-1.pptx of python by computer
Python Programming-1.pptx of python by computerPython Programming-1.pptx of python by computer
Python Programming-1.pptx of python by computer
 
web programming UNIT VIII python by Bhavsingh Maloth
web programming UNIT VIII python by Bhavsingh Malothweb programming UNIT VIII python by Bhavsingh Maloth
web programming UNIT VIII python by Bhavsingh Maloth
 
1.Basic_Syntax
1.Basic_Syntax1.Basic_Syntax
1.Basic_Syntax
 
Python basic syntax
Python basic syntaxPython basic syntax
Python basic syntax
 
Python and You Series
Python and You SeriesPython and You Series
Python and You Series
 
20120314 changa-python-workshop
20120314 changa-python-workshop20120314 changa-python-workshop
20120314 changa-python-workshop
 
Python training
Python trainingPython training
Python training
 

Dernier

Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...amitlee9823
 
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...SUHANI PANDEY
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionfulawalesam
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...amitlee9823
 
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort ServiceBDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort ServiceDelhi Call girls
 
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangaloreamitlee9823
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxolyaivanovalion
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...amitlee9823
 
Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxolyaivanovalion
 
Smarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxSmarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxolyaivanovalion
 
Edukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxEdukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxolyaivanovalion
 
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Delhi Call girls
 
Capstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramCapstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramMoniSankarHazra
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxolyaivanovalion
 
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...amitlee9823
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...amitlee9823
 

Dernier (20)

Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts ServiceCall Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
 
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
 
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interaction
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
 
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort ServiceBDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
 
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFx
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
 
Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptx
 
Sampling (random) method and Non random.ppt
Sampling (random) method and Non random.pptSampling (random) method and Non random.ppt
Sampling (random) method and Non random.ppt
 
Smarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxSmarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptx
 
Edukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxEdukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFx
 
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
 
Capstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramCapstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics Program
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptx
 
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
 

First Steps in Python Programming

  • 1. First Steps into Python Programming Facilitator: Agbo Dozie
  • 4. Table of Content 1 2 3 4 5 6 7 8 Python. Installation. Practical Uses Why Python? Variables, Datatypes (Strings, Int, Float, List, Tuples, Bool, and Dictionaries) & Formatting Functions & Recursions in Python Arithmetic Operators, Comparators, Loops, & Conditionals File Handling in Python Modules in Python Project & Setup Github
  • 6. | Python. IDEs. Installing Python What is Python? of significant whitespace, as well as the DRY (Don’t Repeat Yourself) principle. Wikipedia (Modified) Installing Python is generally easy, and nowadays many Linux and UNIX distributions include a recent Python. Even some Windows computers (notably those from HP) now come with Python already installed. To check if you have Python on your computer, just open your command prompt and type “Python”. You would see the result below, otherwise you do not have Python installed. In order to download Python however, visit the official Python website https://www.python.org/downloads/ and download the latest version. During installation, watch out and ensure to check the box labeled “Add Python to PATH”. Installing an IDE Installing Python IDEs are the environment in which we would write Python codes. Python comes with its default IDE called IDLE, which like the acronym IDE also stands for “Integrated Development Environment”. Below are some of the most common IDEs. From VSCode to Atom Editor to PyCharm, and to the very lightweight Sublime Text. Python is an interpreted, high-level, general-purpose programming language. Created by Guido van Rossum and first released in 1991, Python's design philosophy emphasizes code readability with its notable use
  • 7. | Practical Uses of Python Web Development Python can be used to make web- applications at a rapid rate using frameworks, such as Flask and Django. Game Development There are libraries such as PySoy and PyGame which is a 3D game engine supporting Python 3. Machine Learning & AI Machine Learning and Artificial Intelligence are the talks of the town as they yield the most promising careers for the future. Data Science & Data Visualizations Libraries such as Pandas, NumPy help you in extracting information. We can also use libraries like Matplotlib and Seaborn for visualizations. Desktop GUI Python can be used to program desktop applications. It provides the Tkinter library that can be used to develop user interfaces. Webscraping Applications Python can be used to pull a large amount of data from websites which can then be helpful in various real-world processes. Business Applications Business Applications cover domains such as e-commerce, ERP and many more. Audio & Video Apps Python can be used to develop Video and audio applications such as TimPlayer and Cplay. These apps often provide better stability and performance compared to other media players. CAD Applications Computer-Aided Designs apps can be complicated, but Python makes this simple. Example is Fandango. Embedded Apps Python is based on C which means that it can be used to create Embedded C software for embedded applications.
  • 9. | Why Python? ▪ Python is easy to learn ▪ It has a vast community of users ▪ There is plethora of ‘fancy’ career paths for Python developers ▪ Python can be used for Web development ▪ Python is useful in AI and Machine Learning ▪ Python has millions of modules and frameworks ▪ There has been a lot of adoption and shifting by Startups and Corporates to Python
  • 10. | Why Python? try: aFile = open('anyOldFile.txt') myString = aFile.readline() print('File contents are: ') print(myString) except IOError as e: print "I/O error({0}): {1}".format(e.errno, e.strerror) #include <iostream> #include <exception> using namespace std; int main () { int* myarray = NULL; if (myarray) { cout << "Not NULL" << endl; } else { cout << "Is NULL" << endl; } try { int* myarray = new int[1000000000]; } catch (exception& e) { cout << "Standard exception: " << e.what() << endl; if (myarray) { cout << "Not NULL" << endl; } else { cout << "Is NULL" << endl; } } if(myarray) { cout << "Deleting myarray" << endl; delete [] myarray; } cout << "Returning" << endl; return 0; } Python C++
  • 11. 3 Variables, Datatypes (Strings, Int, Float, List, Tuples, Bool, and Dictionaries) & Formatting
  • 12. | Variables Variables are containers for storing data values. Unlike other programming languages, Python has no command for declaring a variable. A variable is created the moment you first assign a value to it. ▪ A variable name must start with a letter or the underscore character ▪ A variable name cannot start with a number ▪ A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ ) ▪ Variable names are case-sensitive (age, Age and AGE are three different variables) RULES for Naming Variables
  • 13. | Datatypes Variables can store data of different types, and different types can do different things. Python has the following data types built-in by default, in these categories: Text Type: str Numeric Types: int , float, complex Sequence Types: list, tuple, range Mapping Type: dict Set Types: set, frozenset Boolean Type: bool Binary Types: bytes, bytearray, memoryview
  • 14. | Formatting String Concatenation String Methods String Formatting There are other string methods from len() to upper(), to lower(). In fact, you can use the dir(string) command to get the methods associated to strings. There are other string formatting techniques as well. There’s the %s method as well as the direct concatenation approach.
  • 16. | Arithmetic Operators Arithmetic Operators Comparison (Relational) Operators Assignment Operators Logical Operators Bitwise Operators Membership Operators Identity Operators Addition Subtraction Multiplication Division Modulus Exponent Floor Division == != <> > < >= <= = += -= *= /= %= **= //= in not in Logical AND Logical OR Logical NOT is is not
  • 17. | Loops Python has two primitive loop commands: • while loops • for loops A loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string). This is less like the for keyword in other programming languages, and works more like an iterator method as found in other object-orientated programming languages. With the for loop we can execute a set of statements, once for each item in a list, tuple, set etc. for for for With the while loop we can execute a set of statements as long as a condition is true.while
  • 18. | Conditionals Python conditionals are used to test if certain conditions or expressions check out. For example, the popular litmus tests of chemistry. In the test, the paper turns red when the paper is dipped in an acid and blue when dipped in a basic solution. Similarly, in conditionals, we use the if and else keywords for “action” and “reaction” respectively.if else You must have noticed the elif keyword; it is not mandatory; you only use it if you have more conditions to test. In other words, your if/else block would work fine without it. elif Read up: Nested Ifs.
  • 20. | Functions in Python A function is a block of code which only runs when it is called. You can pass data, known as parameters, into a function. A function can return data as a result. In Python a function is defined using the def keyword: To let a function return a value, use the return keyword.
  • 21. | Functions in Python Contd. Example: By default, a function must be called with the correct number of arguments. Meaning that if your function expects 2 arguments, you have to call the function with 2 arguments, not more, and not less. Give a function all it wants and it would answer your call, otherwise, it spits out errors.
  • 22. | Recursions ▪ Python also accepts function recursion, which means a defined function can call itself. ▪ Recursion is a common mathematical and programming concept. It means that a function calls itself. This has the benefit of meaning that you can loop through data to reach a result. ▪ >> The developer should be very careful with recursion as it can be quite easy to slip into writing a function which never terminates, or one that uses excess amounts of memory or processor power. However, when written correctly recursion can be a very efficient and mathematically- elegant approach to programming. We consider and example below: What does the recursion below do?
  • 24. | File Handling in Python File handling is an important part of any web application. Python has several functions for creating, reading, updating, and deleting files. We would consider the 4 operations below, i.e, CRUD. The key function for working with files in Python is the open() function. The open() function takes two parameters; filename, and mode. Let’s see the syntax below: Open To open the file, use the built-in open() function. The open() function returns a file object, which has a read() method for reading the content of the file: Read Note: You can return one line by using the readline() method. Also it is always good practice to close a file when you are done using it. To do this, use the close method, i.e f.close().
  • 25. | File Handling in Python Contd. To write to an existing file, you must add a parameter to the open() function: "a" - Append - will append to the end of the file | "w" - Write - will overwrite any existing content Note that new files would be created if they do not already exist. Write To delete a file, you must import the OS module, and run its os.remove() function:Delete
  • 27. | Modules in Python 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. Modules are all about reusability. Take for example the code below: Save this code in a file named mymodule.py. To use the module, we use the import statement. You could wish to import only a function or variable from your module. That wish can be granted without a genie, easily. You see? Just use from and import!
  • 29. | Project & Setup Github Also called “The New Resume”, GitHub is a git repository hosting service. Simply, Github helps you do version control while coding. Most employer’s now ask to see your GitHub repository when applying for developer roles. Setting Up GitHub ▪ Create a GitHub Account ▪ Download and install git from https://git-scm.com/downloads. Choose your laptop’s specification (OS) ▪ Login in GitHub Username and Password in local machine and start We would be more exhaustive on this in our demo session. Cheers! Project: i. An iPython Notebook has been attached and shared. Study the items in it and work the problem underneath. ii. Write a recursion for printing a list of first n Fibonacci numbers. committing changes and pushing files to GitHub!
  • 30. Thank you for Listening… Any Questions? Contact me on: agbodozie660@gmail.com