Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
5 views

Module 2 - Introduction To Python Programming

Uploaded by

indominus12rex
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Module 2 - Introduction To Python Programming

Uploaded by

indominus12rex
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 23

Module 2 –

CSIT 121 – Computer


Programming

Introduction to
Python
Jasmin Tumulak Estudillo, MSIT
Lecturer
Python Programming
Language
https://www.python.org/

2
Why Python?
◉ Top 15 websites made with Python
◉ Netflix, Google, YouTube, Instagram
◉ In-demand

Source: https://www.botreetechnologies.com/blog/top-15-websites-built-with-python/

Source: https://www.northeastern.edu/graduate/blog/most-popular-programming-languages/

3
The Natural Language of
the Computer

Source: https://www.statista.com/statistics/793628/worldwide-developer-survey-most-used-languages/

4
What is Python?
◉ Python is a popular programming language. It was created
by Guido van Rossum, and released in 1991.
◉ It is used for:
◉ web development (server-side),
◉ software development,
◉ mathematics,
◉ system scripting.

5
Getting Started
◉ Installing Anaconda on Windows
◉ Online Jupyter
◉ https://jupyter.org/try

6
Python Syntax
◉ Python Example:
Indentation
if 5 > 2:
print("Five is greater than two!")

7
Python Comments
◉ Used to explain Python Example:
#This is a comment
code.
print("Hello, World!")
◉ Used to make the code
more readable.
◉ Used to prevent
execution when testing
code.

8
Variables Names
◉ Rules for Python variables:
a. A variable name must start with a letter or the
underscore character
b. A variable name cannot start with a number
c. A variable name can only contain alpha-numeric
characters and underscores (A-z, 0-9, and _ )
d. Variable names are case-sensitive (age, Age and
AGE are three different variables)

9
Python keywords

10
Assigning Values

11
Python Data Types

Source: https://www.w3schools.com/python/python_datatypes.asp 12
Python Casting
◉ Type converter functions
◉int()
◉float()
◉str()

13
Python Casting
◉ Type converter functions
◉int()
◉float()
◉str()

14
Operators and Operands
◉ Python divides the operators in the following group
s
:
a. Arithmetic operators
b. Assignment operators
c. Comparison operators
d. Logical operators
e. Identity operators
f. Membership operators
g. Bitwise operators 15
Order of operations
◉ Rules of precedence
◉ Operators with the same precedence are evaluated from left-
to-right
◉ PEMDAS
a. Parentheses
b. Exponentiation
c. Multiplication and both Division
d. Addition and Subtraction
16
Example of evaluating
expression
a. = 2 * (3-1)
= 2 * (2)
=4
b. =(1+1)**(5-2)
=(2)**(3)
=8

17
Example of evaluating
expression
a. = (5 % 5) + (5 / 5) * (5 + 2 / 2 - 1)
= 0 + 1.0 * (5 + 1.0 – 1)
= 0 + 1.0 * (6.0 – 1)
= 0 + 1.0 * 5.0
= 0 + 5.0

18
Statements
◉ A statement is an instruction that the Python
interpreter can execute.
◉ Examples
◉ while statements, for statements, if
statements, and import statements.

19
Input Statement
◉ There is a built-in function in Python for getting
input from the user:.

20
Programming Exercises
◉ Write the pseudo code
and draw a flowchart
that will accept the
price and quantity.
Compute and output
the total sales.

21
Python Code

22
References

◉ How to Think Like a Computer Scientist — How to Think Like a


Computer Scientist: Learning with Python 3. Openbookproject.net.
(2012). Retrieved 5 April 2022, from
http://openbookproject.net/thinkcs/python/english3e/index.html.

◉ Python Tutorial. W3schools.com. (2022). Retrieved 6 April 2022,


from https://www.w3schools.com/python/

23

You might also like