Lecture 01 Introduction
Lecture 01 Introduction
2022/23
Reading assignment:
Chapter 1 of the textbook
Learning programming with robots
(You may download the PDF file on Hisnet site)
2
GOALS OF THE COURSE ASTU
Two-level goals
- Building up a basis on ICT (Information and
Communications Technology)
- Computational thinking and programming
(but not learning a programming language Python)
3
WHAT IS COMPUTATION ? ASTU
Knowledge
Declarative Imperative
5
ASTU
Guess G,
ex) x= 20, G=4
• Calculators
7
Fixed program computers ASTU
• The Atanasoff–
Berry computer
(ABC) was the
first automatic
electronic digital
computer,
• An early
electronic digital
computing device
8
Fixed program computers ASTU
9
ASTU
Memory
Data Program
Instruction 1
Instruction 2
………………
Instruction k
………………
Instruction N
Processor
Input Output
Control unit ALU
PC k
10
ASTU
Computation
12
ASTU
Top-down design
Decomposing a problem into smaller sub-problems
Multi-level abstraction
Divide and conquer
13
ASTU
Open software
16
ABOUT PYTHON ASTU
Why Python ?
A programming language easy to learn and very powerful
- Used in many universities for introductory courses
- Main language used for web programming at Google
- Widely used in scientific computation, e.g., at NASA
Characteristics of Python
Instruction set
Arithmetic and logical operations for defining
+, -, *, /, and ** expressions
and, or, not
Assignment
Conditionals
Iterations
Input/output
No pointers
No declarations
19
ASTU
Why programming ?
20
2D ROBOT CONTROL ASTU
Interactive mode
Python programs (scripts)
21
14
ASTU
Integrative mode
Script mode
23
ASTU
Functions
A function definition specifies the name of a function
and the sequence of statements that are executed when
the function is called.
def print_message():
print("CSE1061 is fantastic!")
print("Programming is fun!")
Key word
You can call a function inside another function:
def repeat_message():
print_message()
colon
print_message()
Indentation
24
ASTU
Flow of execution
def print_message():
print("CSE1061 is fantastic!")
print("Programming is so much fun")
function definitions
def repeat_message():
print_message()
print message()
repeat_message() function calls
print(‘Done’)
Comments
26
ASTU
Turning right
Define a
function!
def turn_right():
hubo.turn_left()
hubo.turn_left()
hubo.turn_left()
27
ASTU
Newspaper delivery
Climbing up stairs
def climb_up_four_stairs():
climb_up_one_stair()
climb_up_one_stair()
climb_up_one_stair()
climb_up_one_stair()
def climb_up_one_stair():
hubo.turn_left()
hubo.move()
turn_right()
hubo.move()
hubo.move()
def turn_around():
hubo.turn_left() 29
hubo.turn_left()
ASTU
Iteration: for-loops
def climb_up_four_stairs():
climb_up_one_stair()
climb_up_one_stair()
climb_up_one_stair()
climb_up_one_stair()
def climb_up_four_stairs():
for i in range(4):
climb_up_one_stair()
30
ASTU