Python_lesson1
Python_lesson1
Engineering
Programming
McS. Nguyen, Vuong Thuy Ngan
TODAY
01 Course info
02 What is computation
03 Python basics
04 Mathematical operations
Master of Science:
Radio Physics and Application – VNU-HCMUS
Computer Science – Texas Tech University, US
Research direction:
Medical image processing;
Visualization and big data analysis;
Nguyễn Vương Thùy Ngân
EEG classification;
Lecturer
EMG analysis;
Active Noise Control; Active Echo Control;
nvtngan@hcmus.edu.vn
TA profile
Master of Science:
?, VNU-HCMUS
vhttien@hcmus.edu.vn
Final exam
50%
COURSE POLICIES
Communication:
Check Microsoft Teams regularly for updates and resources.
For queries, email the instructor or TA with a clear subject line, including your
name and course code.
Attendance
Taking attendance for each session
If you are unable to attend a session, inform the instructor/TA in advance with
a valid reason.
Use of Technology
Laptops and tablets are allowed for course-related purposes only.
Refrain from using phones or other devices for non-educational activities
during class.
FAST PACED COURSE
New to programming?
PRACTICE. PRACTICE? PRACTICE!
PRACTICE
KNOWLEDGE PROGRAMMING
OF CONCEPTS SKILL
TOPICS
Representing Knowledge: Utilizing data structures to model and
organize information.
Iteration and Recursion: Exploring these computational
metaphors to solve problems.
Abstraction: Understanding procedures and data types to
simplify complex systems.
System Organization: Modularizing code with object classes
and methods.
Algorithm Classes: Studying various algorithms, including
searching and sorting techniques.
Algorithm Complexity: Analyzing the efficiency and scalability
of algorithms.
Advances Topics*
Useful Links
https://www.w3schools.com/python/
http://www.pythontutor.com/
http://www.codecademy.com/tracks/python
http://www.singpath.com
Online compiler
https://onecompiler.com/python
per second?
How many number can you
remember in 3 second?
3.14159265359
WHAT DOES A COMPUTER
DO
What kinds of calculations?
Fundamentally
Performs calculations Built-in
a billion calculations/sec! Ones that you define
as the programmer
Remembers results
Tetrabytes of storage!
If you don’t study, you will watse both your time and
my time
3 9 16/3 4.17
1+2+3 = an algorithm!
COMPUTERS ARE MACHINES
CONTROL ARITHMETIC
UNIT LOGIC UNIT
program counter do primitive ops
INPUT OUTPUT
MEMORY STACK
Address
x076550
x076551
x076552
x076553
MEMORY STACK
Address
x076550
x076551
x076552
x076553
MEMORY STACK
Address
x076550
x076551
x076552
x076553
STORED PROGRAM COMPUTER
sequence of instructions stored inside computer
built from predefined set of primitive instructions
1. arithmetic and logic
2. simple tests
3. moving data
English: words
Word Cloud copyright Michael Twardos, All Right Reserved. This content is excluded from our Word Cloud copyright unknown, All Right Reserved.
Creative Commons license. For more information, see https://ocw.mit.edu/help/faq-fair-use/. This content is excluded from our Creative
Commons license. For more information, see
https://ocw.mit.edu/help/faq-fair-use/.
ASPECTS OF LANGUAGES
syntax
English
programming language
programming language
programming language
have only one meaning but may not be what programmer intended
WHERE THINGS 01 syntactic errors
common and easily caught
GO WRONG
02 static semantic errors
some languages check for these
before running program
can cause unpredictable behavior
>>> type(5)
int
>>> type(3.0)
float
TYPE CONVERSIONS (CAST)
In [11]: 3+2
Out[11]: 5
In [12]: print(3+2)
5
EXPRESSIONS
variable value
pi = 3.14159
pi_approx = 22/7
value stored in computer memory
an assignment binds name to value
retrieve value associated with name or variable by invoking the
name, by typing pi
ABSTRACTING EXPRESSIONS
why give names to values of expressions?
to reuse names instead of values
easier to change code later
pi = 3.14159
radius = 2.2
area = pi*(radius**2)
Variable Names
Must start with a letter or an underscore (_)
Valid: x, _name, user1
Invalid: 1user, -var
Can contain letters, numbers, and underscores
Valid: user_name, value123, x_2
Invalid: user-name, value@
Cannot be a reserved keyword
Python keywords like for, if, else, class, etc., cannot be
used as variable names.
Case-sensitive
myVar and myvar are treated as distinct variables.
Should not include spaces
Use underscores (_) for readability instead of spaces.
PROGRAMMING vs MATH
pi = 3.14159
radius = 2.2
# area of circle
area = pi*(radius**2)
radius = radius+1 <=> radius =+1
CHANGING BINDINGS
can re-bind variable names using new assignment statements
previous value may still stored in memory but lost the handle
for it
value for area does not change until you tell the computer to
do the calculation again
pi = 3.14 3.14
radius = 2.2 pi
2.2
area = pi*(radius**2) radius
3.2
radius = radius+1 area
15.1976
Feedback
End....
contact using MSTeam/Email
nvtngan@hcmus.edu.vn