Advanced Python Programming: Welcome To

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 19

Welcome to

Advanced Python Programming


An online certification course
Course Contents

1. Introduction 23. Conditionals 45. Special methods


2. The Programming Cycle for Python 24. Conditionals (continued) 46. Class example
3. Getting Started 25. Expression evaluation 47. Inheritance
4. Variables and simple data types 26. Float representation 48. Inheritance and OOPS
5. Elements of python 27. Dictionaries 49. Files and exceptions
6. Type conversion 28. User input and loops 50. File I/O
7. Expressions 29. Break and continue 51. Exceptions
8. Assignment statement 30. Function 52. Testing your code
9. Arithmetic operators 31. Parts of a function 53. Assertions
10. Operator precedence 32. Execution of a function 54. Iterators
11. Boolean expression 33. Keyword and default arguments 55. Recursion
12. Introducing lists 34. Scope rules 56. Simple search
13. Working with lists 35. Strings 57. Estimating search time
14. For loop 36. Indexing and slicing of strings 58. Binary search
15. Nested loops 37. More slicing 59. Estimating Binary search time
16. Tuples 38. Higher order functions 60. Recursive Fibonacci
17. Unpacking sequences 39. Sieve of Eratosthenes 61. Tower of Hanoi
18. Lists 40. Abstract data types 62. Sorting
19. Mutable sequences 41. Classes 63. Selection sort
20. List comprehension 42. Modules 64. Merge list
21. Sets 43. Importing modules 65. Merge sort
22. If statements 44. Classes 66. Higher order sort
Introduction

What is Python?

It is a general purpose, high-level, and interpreted programming language

Python Features

It is simple and easy.

It is a general purpose, high-level, interpreted programming language.

It supports Cross platforms.

It is Free and Open Source.

It has huge community and large ecosystem of Libraries, frameworks, and tools.

It supports both Object Oriented and Procedure Oriented programming.


Introduction

Where do we use Python?

Used to develop Windows Applications

Used to develop Web Applications

Used to develop Mobile Applications

Used in the field of AI, ML, and Data Science

Used in Hacking

Used in Testing and Game development

Python History
The Programming Cycle for Python

Start Application

No compile or link steps


Test the behaviour
Python programs simply import modules at
runtime and use the objects they contain.

Because of this, Python programs run Stop Application


immediately after changes are made.

Edit the Code


Getting Started
Setting-up the Environment

Install Python - https://www.python.org/downloads/

Install IDE - PyCharm - https://www.jetbrains.com/pycharm/

- Jupyter - https://jupyter.org/install.html

- Spyder - https://github.com/spyder-ide/spyder

- Atom - https://atom.io/

- Thonny - https://thonny.org/
Variables and Simple Data types
What is variable? Syntax

It is a data holder variableName = dataValue

Naming Rules

A variable name must start with a letter or the underscore character, but not with number.

A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )

A variable name does not contain any special symbol except underscore( _ ).

A variable name should not be a keyword.

Variable names are case-sensitive.


Variables and Simple Data types
Data types in Python

None

Numeric – int, float, complex, and bool

String

List
Tuple

Set

Range
Dictionary
Elements of Python
What is element?

Element is defined as an individual part of Python program.

Elements of Python

Keywords – Reserved words with specific meaning

Identifiers – User specified names

Literals – Data values like string, numbers, collections

Operators – Symbols used to perform arithmetic and logical operations.


Elements of Python
Operators

Arithmetic Operators → +, -, *, /, **, //

Assignment Operators → =, +=, -=, *=, /=, **=, //=

Comparison Operators → <, <=, >, >=, ==, !=

Logical Operators → and, or, not


Bitwise Operators → &, |, ^, ~, <<, >>

Identity Operators → is, is not

Membership Operators → in, not in


Type Conversion in Python
What is type conversion?

The process of converting data value from one data type to another

Built-in functions for type conversion

int(variable) – Converts any value to decimal integer

int(variable, base) – Converts any value to integer of specified base

float(variable) – Converts any value to float

str(variable) – Converts any value to string


Type Conversion in Python
What is type conversion?

The process of converting data value from one data type to another

Built-in functions for type conversion

ord(variable) – Converts character value to integer

hex(variable) – Converts an integer value to hexadecimal value

oct(variable) – Converts an integer value to octal value

bin(variable) – Converts an integer value to binary value

chr(variable) – Converts a number to corresponding ASCII value


Expressions in Python
What is expression?

An expression is a set of operators and operands that represent a value

Expressions are representations of value

Operator Operand
= identifier

+ Literals

and

is not

<<
Expressions in Python

Examples
“hello” [number for number in range(10)] - List

average = sum / count {key : key*10 for key in range(5)} - Dictionary

num_1 < num_2 list(value for value in range(10)) - Generator

20 == 25 value_1 if True else value_2 - Conditional

a < b and a < c


Assignment Statement in Python
What is assignment statement?

The assignment statement used to assign a value to a variable

=
Syntax
variableName = value
variableName = anotherVariableName
variableName = expression
Arithmetic Operators in Python

The operator used to perform arithmetic operations

+ Addition | Concatenation
- Subtraction
** Exponent

* Multiplication | String repeater


// Floor Division

/ Division
% Remainder
Operator Precedence in Python
Precedence Operator
What is operator precedence?
1 () [] {}
2 Subscription, slicing, call, attribute
3 **
Operator precedence decides the 4 +x, -x, ~x
order of operators to be evaluated in 5 *, /, //, %
an expression
6 +, -
7 <<, >>
8 &
9 ^
10 |
11 in, not in, is, is not, <, <=, >, >=, !=, ==
12 not x
13 and
14 Or
Boolean expression in Python
What is Boolean expression?

An expression that evaluates to True or False

How Boolean expressions are build?

Using Boolean value directly

Using Comparison operators

Using Logical operators bool(value)


Using Identity operators

Using Membership operators


Boolean expression in Python
What is True? What is False?
A boolean value True A boolean value False

An expression evaluated to True An expression evaluated to False

A non-empty String An empty String

A non-zero number A number zero

Any non-empty list, tuple, set, dictionary Any empty list, tuple, set, dictionary

Value None

You might also like