Chapter 1 - Slide
Chapter 1 - Slide
Programming
Chapter 1 : DEC40092 (Computer Vision Programming)
What is Python?
Intro
Started by Guido van Rossum to express ideas in fewer lines of code without
reducing any readability.
Simple - no need specific IDE to run Object Oriented - python creating and using classes and
objects are downright easy
Free and Open Source - no charge, easy download
Extensible - can write other language (eg: C++) in Python
High Level Language - can be understable by human / code
English look-alike
Embeddable - can put system into different states, set
Portable - Can be run on any platform configurations and test all sort of real-world use cases
(Win/Linux/MacOS)
Extensive Libraries - huge collection libraries all over
Interpreted - because it goes through an interpreter internet
which turn code into computer language
1.2 Install Python
Windows - 7, 8.x, 10
Mac - OS X, MacOS
- From an expert
This is the most
important takeaway
that everyone has to
remember…..
1.3 Understand syntax in Python
1.3.1 Identify the basic syntax in Python
Identifier - An identifier is a name given to entities like Quotation - can be use as comment or also represent as
class, functions, variable, etc. It helps to differentiate string
one entity from another
Comments - as a reference but not included into our
Reserved Words created programming code
Lines and Indentation - to define a block of code Multiple statements - similar to multi-line statements
but this is how to make multiple line statements into a
Multi-line statement - to make it easier to write and read single line.
if the statements are too long
Docstring - short for documentation string
Identifier (The rules)
Additional : exec
Multiple line of comment using # Multiple line of comment using ‘’’ or “””
Multiple statements
1.4 Identify basic structure in
Python
1.4.1 Explain the data types in Python
Numbers
OUTPUT:
Strings (1/2)
a collection of one or more characters put in single '___' , double ''___" or triple quotes '''___'''
Strings (2/2)
OUTPUT :
List (1/2)
No duplicate members.
OUTPUT :
1.4.2 Explain basic operators in Python
Arithmetic Operators
Assignment Operators
Bitwise Operators
Membership Operators
Identity Operators
Arithmetic Operators
Comparison / Relational Operators (1/2)
Comparison / Relational Operators (2/2)
Assignment Operators
Bitwise Operators
Membership Operators (1/2)
Output:
while Loop with else
Example: Output:
loop with continue statement (1/2)
Example: Output:
1.4.4 Describe modules in Python
To break down large programs into small Python Built-in Modules - type help (‘modules’)
manageable and organized files. in command prompt OR in IDLE.
Example: Output:
Example 1: Example 3:
Example 2:
1.4.5 Functions (1/2)
Types of functions:
Output:
Advantages of user-defined functions (1/2)
Example 1: Output 1:
Function arguments (2/3)
Any error?
Input Function
BP2
JKE PSAS
019 - 730 7570