Professional Documents
Culture Documents
S01 Notes
S01 Notes
Seminar 1:
Introduction &
Programming Basic
* Beller, Michael J.; Alan Barnett (2009‐06‐18). "Next Generation Business Analytics". Lightship Partners LLC. Retrieved 2009‐06‐20.
2
1
7/15/2020
Course Objectives
By the end of this course, you will be able to:
1. Interpret different elements of programming components like
programming syntax, control structures, data types and design
methods.
2. Write codes that allow you to solve simple business problem
programmatically.
3. Derive basic analytics outcome from managing data.
4. Present data graphically that aid and support decision with
appropriate statistical and graphing modules or use visualization
software.
2
7/15/2020
Course Assessment
WHY PROGRAMMING?
3
7/15/2020
Purpose of Programming
• Giving instruction for computer to do something.
• Programming is the bridge between computer and
human.
4
7/15/2020
• Role of computer
– Execute the instruction using computer
resources.
– The instruction can be:
• Make a button on the screen
• Put on the screen a message
• Compute the sum
• Can you think of more?
10
5
7/15/2020
11
11
First published computer program by Ada Lovelace.
Source: https://en.wikipedia.org/wiki/Ada_Lovelace#First_computer_program
12
12
6
7/15/2020
13
13
Why Python?
https://spectrum.ieee.org/at‐work/innovation/the‐2018‐ https://www.codingdojo.com/blog/top‐7‐programming‐
top‐programming‐languages languages‐of‐2020 14
14
7
7/15/2020
Program
● A program is a list of statements.
● Statement contains definition,
assignment, expression.
● Elements of programming:
○ Variables (words)
○ Controls (sequence)
○ Functions (repeat a set of
sequence)
15
Variable Semester 1
Current_Module:
AB1234
• A variable is a placeholder.
• You make the placeholder
and puts in content
Current_Module:
• The content is changeable -
Semester 2
> Variable BC4512
16
8
7/15/2020
Constant
• A variable can sometimes My_NRIC:
be used to hold fixed S9512345G
value -> Constant
• See the illustration on the
right, NRIC can be a
constant as its value does
not change.
17
Components of Variable
• Name
– That will be used to
call the variable in
future
• Assignment operator
– To link up value(s) to a
particular variable
• Value(s)
– The data this variable
holds
18
9
7/15/2020
Variables
● Define:
○ postcode = 801244
○ postcode_str = “801244”
○ postcode_valid = True
○ postcodes = [“801244”, “801223”, “801254”]
● Use:
○ print(postcode)
○ print(“My postal code is “, postcode)
○ postcode = postcode + 100000
○ print(“The first postal code is “, postcodes[0]) 19
19
Data Types
Data Type Example
Numeric (integer, float): x = 1 ; y = 1.02
Boolean (True / False): valid = True
Tuple: subsidiaries = (“breadtalk”, “foodrepublic”)
Dictionary: ages = {“Jane”: 16, “tom”: 20}
20
20
10
7/15/2020
Programming Statements
● Program: Recall this:
x = 10
y = 2
z = x ‐ y
z1 = x * 2
z2 = y / 3
print("z = ", z)
● Elements:
○ Variables ‐> x, y, z, z1, z2
○ Functions ‐> print()
○ We will see a few more functions
before coming to control 21
21
22
22
11
7/15/2020
● Convert to float:
○ tax_rate = float(“5.12”)
● Convert to string:
○ newpostcode = str(postcode)
● Convert to list:
○ names= list(name) 23
23
24
24
12
7/15/2020
25
25
13