Download as pdf or txt
Download as pdf or txt
You are on page 1of 38

INFT 625

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)

Faisal Mehmood (TA)


• Thu – 5:30 pm to 6:30 pm
• Sat + Sun – 1:00 pm to 2:00 pm

3
What is a Computer Program?
• A set of instructions meant to be executable by a
computer.

• It’s a means of communication with a computing


machine.

4
What is a Computer Program?
• A computer program is also known as code and
the activity of programming is also known as
coding.

• So, the words code and program are synonyms


and so are the activities of coding and
programming.

5
Program vs Software
• These are synonymous words for the most part.

• The word software is used in a more generic sense


encompassing not just programs but data files as well.

• The word software originated to contrast with


hardware.
Hardware → something tangible/physical.
Software → something non-tangible/non-physical.

6
Why Do We Need to Know
Programming?
• Humans need to understand programs for writing,
maintaining, sharing, and trouble shooting.

• We haven’t advanced yet to the level that we can tell


machines what to do in our language and they perfectly
understand it.

• And hence, we need to learn a language that the machine


could understand or at least be translated into what they
can understand.
7
Why is it so Difficult to
Understand Human Speech?
• ONE REASON: It is vague and ambiguous.

• Examples:
Small Animal Clinic.
(Is it a small clinic of animals or a clinic of small animals?)

Zaid went for a walk with his friend in red shirt.


(Was Zaid wearing a red shirt or his friend?)

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:

• Also called structural or grammatical ambiguity.

• It occurs b/c the sentence structure leads to two or more


possible meanings.

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

The chicken is ready to eat.


This has two different meanings:
The chicken is cooked and is ready to be eaten.
The chicken itself is read to eat some food.

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

• The explosion of the Ariane 5 rocket incident.


https://www-users.cse.umn.edu/~arnold/disasters/ariane.html
https://www.bbc.com/future/article/20150505-the-numbers-that-
lead-to-disaster

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.

• An algorithm is a solution to a problem

• An algorithm is a solution to a problem expressed in a simple easy to understand


language by humans for humans.

• A program is always in a language that a computer understands.

• An algorithm is almost always in a language that a computer does not understand


but that is extremely easy for a human to understand.

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.

• The solution to a computational problem when expressed


independent of any programming language is called an
algorithm or pseudocode.

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.

• So, an algorithm is a solution to a problem expressed independent of a


programming language.

• It is used as a means of sharing the solution among programmers of different


languages.

• It is used by the programmer to gather/structure their thoughts about the solution.

• It is an informal way of expressing solution.

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

• Modules (or functions)

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.

• Hence we use pseudocode. It is like code but the rules are


relaxed and the instructions are not fixed. You can use English-
like words for instructions.

26
What is Computing?
• Computing is an act of taking an input, processing it, and producing
an output.

• The input could be from any of the user input mechanisms:


keyboard, mouse, touch screen, camera, mic, file system
(database), scanner, USB, internet, cloud storage, hard drives,
sensors, RAM (main memory) (shared memory locations), ROM,
CD/DVD, fax, etc.

• Output could be to any of these: printer, monitor, hard drive, RAM


(main memory), speakers, internet, cloud storage, CD/DVD, fax etc.

27
Standard Input/Output
• This is also known as terminal.

• Consists of keyboard and monitor.

• Keyboard is the standard input device and monitor is the


standard output device.

28
Why do Business Students Need
to Learn Programming?
• It teaches how to think. (It is about logic and its implementation)

• Understanding computers and learning to code helps one


develop an appreciation of how IT works and get a deeper
understanding of IT system.

• Coding also helps develop a new perspective towards problem


solving.

29
Why do Business Students Need
to Learn Programming?
• It teaches us to be creative. A very effective creative medium.

• Computer programming is THE future!

• Coding is no longer a skill only for programmers or computer


science people. In a competitive business job market, the ability
to code makes your resume more attractive.

• You can open your own business.


30
Why do Business Students Need
to Learn Programming?
• Helps you to automate your everyday tedious manual tasks.
• Better use of Tableau, PowerBI or MS Excel.
• Clean and organize your data, files, etc.
• Interact with you email client.
• Fill out pdf forms and excel files.
• You can scrap data from the internet.
• You can convert image files from one format to another.
• Perform quick math operations and solve equations.

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.

• This comes in handy as a programmer.

• If you are starting a coding career, we encourage you to


play some games and to give your logical thinking skills
a boost.
34
Game-Based Teaching/Learning
• These could be actual games used in teaching/learning
activities.

• Or it could be the borrowing of certain gaming principles and


applying them to real-life settings.

• It is about incrementally introducing concepts guiding students


towards an end goal.

• Involves competition, points, incentives, feedback loops etc.


35
Game-Based Teaching/Learning
• When a student works on game-based learning, they’re
probably just thinking that they’re having fun with a game.

• 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

You might also like