1-Introduction-to-Python-Programming
1-Introduction-to-Python-Programming
Python Programming
Object Oriented Programming (CpE 2)
Engr. CJASantos
Contents
1. Introduction to Python
2. The print() function, output formatting
3. Comments
4. Indentation
5. Variables
6. Data Types
7. Casting
8. The input() function
9. Operations and Expressions
Introduction to Python
What is Python?
• Python is an interpreted, object-oriented, high-level
programming language.
• It was created by Guido van Rossum, and released in 1991.
Introduction to Python
Requirements
• Python Interpreter
• Text Editor:
o Sublime
o VS Code
• IDE Integrated Development Environment (Optional):
o PyCharm
o Anaconda
Introduction to Python
Comments Examples:
• Comments starts with a #, and
Python will ignore them.
• Comments can be placed at the end
of the line, and Python will ignore
the rest of the line.
• A comment does not have to be text
that explains the code, it can also be
used to prevent Python from
executing code:
Comments
Multi-line Comments
Example:
Indentation
Indentation Example:
Syntax Error
• Indentation refers to the spaces at
the beginning of a code line.
• Where in other programming
languages the indentation in code is
for readability only, the indentation Correct
in Python is very important.
• Python uses indentation to indicate
a block of code.
Variables
Variables Example:
Naming Variables
Legal variable names: Illegal variable names:
Variables
• Camel Case – Each word, except the first, starts with a capital letter.
Example: myVariableName = “Programming”
• Pascal Case – Each word starts with a capital letter.
Example: MyVariableName = “Programming”
• Snake Case – Each word is separated by an underscore character.
Example: my_variable_name = “Programming”
Variables
Example:
Variables
Casting Example:
Casting Examples:
Python Arithmetic
Operators
• Arithmetic operators
are used with numeric
values to perform
common mathematical
operations:
Operations & Expressions
Python Assignment
Operators
• Assignment operators
are used to assign
values to variables:
Operations & Expressions
Python Comparison
Operators
• Comparison
operators are used
to compare two
values:
Operations & Expressions
Example:
Seatwork