Professional Documents
Culture Documents
PDS-L01-Introduction
PDS-L01-Introduction
Programming for
Data Science
Dr. Asim Khwaja
Session 01
Grading Policy
Assessments Percentage
Quizzes 20%
Assignments 20%
CP 10%
Mid Term Exam 25%
Final Exam 25%
2
Office Hours
Dr Asim Khwaja
• Thu – 1 Hr After Class (10:00 pm to 11:00 pm)
• Sun – 1 Hr (5:00 pm to 6:00 pm)
3
What is a Computer Program?
• A set of instructions meant to be executable by a
computer.
4
What is a Computer Program?
• A computer program is also known as code and
the activity of programming is also known as
coding.
5
Program vs Software
• These are synonymous words for the most part.
6
Why Do We Need to Know
Programming?
• Humans need to understand programs for writing,
maintaining, sharing, and trouble shooting.
• Examples:
Small Animal Clinic.
(Is it a small clinic of animals or a clinic of small animals?)
8
Why is it so Difficult to
Understand Human Speech?
Lexical / Semantic Ambiguity:
B/c of poor vocabulary usage that leads to multiple possible
meanings.
My sister saw a bat.
It has four different meanings:
My sister saw a bat (saw the past tense of see) (bat the bird)
My sister saw a bat (saw the past tense of see) (bat the wooden bat)
My sister saw a bat (saw as cutting) (bat the bird)
My sister saw a bat (saw as cutting) (bat the wooden bat)
9
Why is it so Difficult to
Understand Human Speech?
Syntactic Ambiguity:
10
Why is it so Difficult to
Understand Human Speech?
I invited the person with the microphone.
This has two different meanings:
I spoke (using the microphone) to invite the person.
I invited the person (who has the microphone).
11
Why is it so Difficult to
Understand Human Speech?
Let’s eat grandma.
This has two different meanings:
Talking to grandma inviting her to start eating.
Planning to eat grandma herself.
12
ACTIVITY 1
• Why programming a machine is different and complex.
• Blindfold activity.
13
ACTIVITY 2
Finding the maximum number from a list of integers:
• You can only look at one number at a time.
• Your short-term memory is like that of an ostrich.
• You are allowed to write one number in a specific place, and
you can compare that written number with the card you are
viewing at that time.
• If you need to write another number to remember, you must
erase the last one (and that means you have forgotten the last
one).
14
ACTIVITY 3
Finding the maximum number from a list of integers
(different rules this time):
• You can only view two cards at a time faceup.
• If you want to faceup a third card, you must facedown one of
the other faced-up cards.
• Now you don’t have any boxes to write anything.
• Again, your short-term memory is like that of an ostrich.
• You can do only two operations: compare the two faced-up
cards and swap them if you like (i.e., swap their positions).
15
ACTIVITY 4
Sort the number list in ascending order following the
same restrictions as that of activity 3.
• You can only view two cards at a time faceup.
• If you want to faceup a third card, you must facedown one of
the other faced-up cards.
• Now you don’t have any boxes to write anything.
• Again, your short-term memory is like that of an ostrich.
• You can do only two operations: compare the two faced-up
cards and swap them if you like (i.e., swap their positions).
16
Poor Programming Can Threaten
Lives! – CASE STUDIES
• Therac-25 incident.
https://en.wikipedia.org/wiki/Therac-25
17
Program vs Algorithm?
• An algorithm is a step-by-step description of the solution to a problem such that if
followed from step 1 all the way to the last step in sequence, it will result in
solving that problem.
18
Program vs Algorithm?
• The solution to a computational problem when expressed in
such a way that a computer can easily understand and execute
it is called a program.
19
Why Algorithms and Why Not
Directly Write Programs?
• We always try to first write an algorithm and later on convert it to a program.
20
Many Types of Computer
Languages
• Python
• C/C++
• SQL (Structured Query Language – SeeQuel) (used to query databases for different
views of the data) (it is used only on relational databases {Oracle, SQL Server, FoxPro})
• Java
• HTML/CSS (used to develop web pages) (document structuring/formating languages)
• Javascript
• GW BASIC
• PHP
• .NET (C#, VB)
• Post Gres
• R
• Swift
21
Elements of a Programming
Language – Recipe
• Begin by mixing sugar and butter together.
• Whisk well until light and fluffy with a manual whisker or
a fork.
• Once done, add the beaten eggs and blend well.
• Beat further so that the mixture turns white and creamy.
• Sift together the all-purpose flour and baking soda.
• Gradually, add this to the egg mixture.
22
Elements of a Programming
Language
• If required, add a little milk, and mix till the batter is fluffy
and soft.
• Now, take a baking tin to cook the cake and grease it
well using some butter or cooking spray.
• Then, sprinkle some all-purpose flour on it.
• Put it in the oven and bake it.
• After the cake is done prepare the icing (see my recipe
for the icing) and spread the icing over the cake.
23
Elements of a Programming
Language
• Simple Statements
• Conditions
• Loops
24
Program vs Algorithm vs
Pseudocode
• Pseudocode means like code.
• Pseudocode is a means of expressing algorithms.
• Why?
• Programming language is precise, concrete, follows strict
grammatical rules, unforgiving, concise, too formal.
• Expressing algorithms in English language is too verbose –
programmers tend to prefer concision. Therefore, not too
convenient and comfortable.
25
Program vs Algorithm vs
Pseudocode
• For expressing algorithms we need:
• Concision
• Not too strict
• Precise enough (not ambiguous)
• Not too formal and not too informal – somewhere in between.
26
What is Computing?
• Computing is an act of taking an input, processing it, and producing
an output.
27
Standard Input/Output
• This is also known as terminal.
28
Why do Business Students Need
to Learn Programming?
• It teaches how to think. (It is about logic and its implementation)
29
Why do Business Students Need
to Learn Programming?
• It teaches us to be creative. A very effective creative medium.
31
32
33
Game-Based Teaching/Learning
• Logic games can give your brain a nice workout by
helping to formalize your thinking into a step-by-step
process.
• But there’s a lot that goes into crafting the game as a learning
tool.
36
The End
37
A Fun Browser-Based Logic
Game
Problem specification
• Your objective in the game will be to find your way through a
labyrinth. You win when you reach the finish tile.
• The labyrinth is full of doors that will often block your way, and
switches that can be used to open and close the doors. Every
door and switch is marked by a letter (or a pair of letters) and a
color. Pressing a switch toggles all doors that have the same
marking.
38