This presentation is a great resource for zero-based Python programmers who wants to learn Python 3. This course includes brief history of Python and familiarity of its basic syntax.
1. Python3: Zero to Hero
Introduction to Python3 Programming Language
July 2017
Chariza Pladin
Data Analyst - Accenture Inc.
chariza.b.pladin@accenture.com
3. COURSE MODULE CODE COMPILER
Python3: Zero to Hero - Introduction to Python Programming
4.
5. High-level programming language for
general-purpose programming, created by Guido
van Rossum and first released in 1991.
Python
6. Python is great for backend web development,
data analysis, artificial intelligence, and scientific
computing. Many developers have also used
Python to build productivity tools, games, and
desktop apps, so there are plenty of resources to
help you learn.
7. Guido van Rossum
● University of Amsterdam
- MA in Mathematics and
Computer Science 1982
● Benevolent Dictator For
Life (BDFL)
● Google (2005 - Dec
2012)
● Dropbox (2012 - Present)
8. “ I was looking for a hobby programming
project that would keep me occupied during the
week around Christmas. My office ... would be
closed, but I had a home computer, and not
much else on my hands. “
15. Very Flexible
As a dynamically typed language, Python is really
flexible. This means there are no hard rules on how to
build features, and you'll have more flexibility solving
problems using different methods.
Furthermore, Python is also more forgiving of errors, so
you'll still be able to compile and run your program
until you hit the problematic part.
24. Modules
Modules can define functions, classes, and variables that
you can reference in other Python .py files or via the Python
command line interpreter.
Modules are accessed by using the import statement.
When you do this, you execute the code of the module,
keeping the scopes of the definitions so that your current
file(s) can make use of these.
31. Variable
A variable is a location in memory used to store some data
(value).
We don't need to declare a variable before using it.
In Python, we simply assign a value to a variable and it will
exist. We don't even have to declare the type of the variable.
This is handled internally according to the type of value we
assign to the variable.
32. Variable Assignment
We use the assignment operator (=) to assign values to a
variable. Any type of value can be assigned to any valid
variable.
33. Multiple Assignment
In Python, multiple assignments can be made in a single
statement as follows:
If we want to assign the same value to multiple variables at
once, we can do this as
43. Data Types
Numeric Types
● int: Integers;
● long: Long integers of non-limited length;
● float: Floating-Point numbers, equivalent to C doubles
● complex: Complex Numbers
Sequences Types
● str: String;
● bytes: a sequence of integers in the range of 0-255; only available in Python 3.x
● byte array: like bytes, but mutable
● list
● tuple
44. Data Types (cont.)
Sets:
● set: an unordered collection of unique objects;
● frozen set: like set, but immutable
Mappings:
● dict: Python dictionaries, also called hashmaps or associative
arrays,
45. Mutable vs. Immutable Objects
Data types in Python can be distinguished based on whether objects of the type are
mutable or immutable. The content of objects of immutable types cannot be
changed after they are created.
Some immutable types: Some mutable types:
int, float, long, complex
str
bytes
tuple
frozen set
byte array
list
set
dict
46. List
List is the most versatile data type available in Python
which can be written as a list of comma-separated values
(items) between square brackets.
Important thing about a list is that items in a list need not
be of the same type.
58. Dictionary
Each key is separated from its value by a colon (:), the
items are separated by commas, and the whole thing is
enclosed in curly braces.
Keys are unique within a dictionary while values may not be.
The values of a dictionary can be of any type, but the keys
must be of an immutable data type such as strings,
numbers, or tuples.
66. Strings
Strings are amongst the most popular types in Python. We
can create them simply by enclosing characters in quotes.
Python treats single quotes the same as double quotes.
Creating strings is as simple as assigning a value to a
variable.
67. Accessing String Values
Python does not support a character type; these are treated
as strings of length one, thus also considered a substring.
68. Updating Strings
You can "update" an existing string by (re)assigning a
variable to another string. The new value can be related to
its previous value or to a completely different string
altogether.
74. Python3: Zero to Hero - Introduction to Python Programming
Python Decision
Making
75. Decision Making
Decision making is anticipation of conditions occurring
while execution of the program and specifying actions
taken according to the conditions.
Decision structures evaluate multiple expressions which
produce TRUE or FALSE as outcome. You need to
determine which action to take and which statements to
execute if outcome is TRUE or FALSE otherwise.
78. Python3: Zero to Hero - Introduction to Python Programming
Python Loops
79. Loops
In general, statements are executed sequentially: The first
statement in a function is executed first, followed by the
second, and so on. There may be a situation when you need
to execute a block of code several number of times.
A loop statement allows us to execute a statement or group
of statements multiple times.
82. Range()
-returns an immutable sequence object of integers between
the given start integer to the stop integer.
Syntax:
range(stop)
range(start, stop[, step])
83. start - integer starting from which the sequence of
integers is to be returned
stop - integer before which the sequence of integers is
to be returned.
The range of integers end at stop - 1.
step (Optional) - integer value which determines the
increment between each integer in the sequence
Range() Parameters
87. LEGB Rule
● Local can be inside a function or class method, for
example.
● Enclosed can be its enclosing function, e.g., if a
function is wrapped inside another function.
● Global refers to the uppermost level of the executing
script itself, and
● Built-in are special names that Python reserves for
itself.
89. Functions
A function is a block of organized, reusable code that is
used to perform a single, related action. Functions provide
better modularity for your application and a high degree of
code reusing.
90. Python3: Zero to Hero - Introduction to Python Programming
Function blocks begin with the keyword
def followed by the function name and
parentheses ( ( ) )
Any input
parameters or
arguments should
be placed within
these parentheses.
You can also define
parameters inside
these parentheses.the documentation
string of the
function or
docstring.
statement return [expression] exits a
function, optionally passing back an
expression to the caller.
91. Docstrings
A docstring is a string literal that occurs as the first
statement in a module, function, class, or method definition.
Such a docstring becomes the __doc__ special attribute of
that object.
92. Comments
Comments are little snippets of text embedded inside your
code that are ignored by the Python interpreter.
A comment is denoted by the hash character (#) and
extends to the end of the line.:
95. Test Cases
● Random Password Generator
● Pangram Word Test
● If-Else Allergic Arithmetic Operations
● Weird Case and Mexican Wave
Python3: Zero to Hero - Introduction to Python Programming
96. Python3: Zero to Hero - Introduction to Python Programming
Ask me
anything about
Python :)