You are on page 1of 13

7/15/2020

Seminar 1:
Introduction &
Programming Basic

What this course covers?

Programming Connecting Codes to Business Analytics


Data Source

Sequence of instructions to Connect codes to external Skills, technologies, practices


be executed by compilers or data sources. File input and for continuous iterative
interpreters and convert to output operation. Connect to exploration and investigation
binary codes understandable database. Connect to of past business performance
by computer. network connection. to gain insight and drive
business planning*.

● Programming Basic ● File input and output ● Descriptive analysis


● Operators and Controls ● JSON ● Data visualization
● Data Types ● API

* 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.

To succeed in this course,


You are expected to...
1. Read and complete pre-lecture materials (reading, video etc).
2. Attend weekly seminar.
3. Attempt workshop questions before each seminar.
4. Participate in in-class activities and exercises.
5. Communicate and solve problems using technology.
6. Bring your own laptop for each seminar.

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.

• What do we do to use this bridge?


– Know how to get to it -> Understanding
– Know how to use it -> Tools
– Know what do we use it for -> Problem
– Know what we want the computer to do -> Solution
– Programming is a tool that creates solution on the
given problem that is developed based on language
and problem understanding.

4
7/15/2020

• How about the bridge?


– Know how to get to the computer -> Programming
Tool
– Get the instruction from programmer -> Programming
Language
– Know how to communicate it to the computer >
Machine Codes
– Programming translates programming codes into
machine codes for computer to execute the
instruction.

• 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

Everyone should know how to


program a computer, because it
teaches you how to think!
- Steve Jobs

11

11

What is a computer program?


• Series of statements for computer to execute
• Program allows you to design the way you want computer to 
do something.
• Program allows us to utilise it to solve problems 

First published computer program by Ada Lovelace.
Source: https://en.wikipedia.org/wiki/Ada_Lovelace#First_computer_program
12

12

6
7/15/2020

High Level Language:


The Language - Closer to human language.
- Do not need hardware knowledge.
- Example: Python, Java, Visual
Basic.

Low level language:


- Machine level language.
- Tie to hardware architecture.
- Example: VHDL, assembly
language.

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

• See the illustration on the


right, Current_Module can
be a variable as its value
keeps changing, semester 1
is AB1234 as value,
semester 2 can be 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

String: y_string = “1.02”

Boolean (True / False): valid = True

List: postcodes = [“801244”, “801223”, “801254”]

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

Functions on Type Conversion


● We have learnt that different variables serve different purposes.
● Numeric for mathematical computation
● String to make text representation
● Boolean for decision making
● Sometimes the data comes in different type that may not be what we want.
● Solution ‐> Convert the type
● Function for checking on the type, type(variable):
x = 10
type(x) # int
x = “10.0”
type(x) # str
• The # hashtag is for comments, things that you do not want python to run.

22

22

11
7/15/2020

Functions on Type Conversion


● Convert to integer:
○ newpostcode = int(postcode_str)

● Convert to float:
○ tax_rate = float(“5.12”)

● Convert to string:
○ newpostcode = str(postcode)

● Convert to list:
○ names= list(name) 23

23

Function for Getting User Input


● The input() function gets input from user:
○ name = input(“Name please?”) 
1. Prompts a message “Name please?”
2. Then wait for user to enter a value.
3. After which, it then store the value entered by user into a 
variable called name
○ age = int(input(“Your age?”)) 
1. Prompts a message “Your age?”
2. Wait for user to enter a value.
3. Value entered from user is always in string data type.
4. int() then converts the string into integer data type.

24

24

12
7/15/2020

You have learnt...


1. Program is instruction for computer to execute
2. To define various types of data types.
3. To construct python codes with inputs and outputs

25

25

13

You might also like