Week 1
Week 1
Welcome to EE132
Introduction to Computing
and Data Science
Kashif Javed
[email protected]
Professor of Electrical Engineering
2
Logistics
• Lectures:
▪ Section A : Mon (9:00 - 10:00 am) and Wed (9:00 – 11:00 am)
▪ Section B : Mon (10:00 - 11:00 am) and Tue (9:00 – 11:00 am)
▪ Location: (EE014)
• Office hours:
▪ Day Time Location
Tue 12 - 1 pm EE Faculty room
Thurs 12 - 1 pm EE Faculty room
3
Grading Policy
• 2 Quizzes: 2 x 5% = 10%
4
About the Course
• This course serves as a rigorous introduction to computer programming.
▪ Object-oriented design,
▪ Program complexity,
5
About the Course
• New to programming? PRACTICE. PRACTICE? PRACTICE!
6
About the Course
7
Recommended Books
• John Guttag, Introduction to Computation and Programming Using Python:
With Application to Understanding Data, 3rd edition. MIT Press, 2021
• Deitel and Deitel, Intro to Python for Computer Science and Data Science:
Learning to Program with AI, Big Data and The Cloud, Pearson Education
Limited 2022
8
Prerequisites
• None
9
CLO Description
10
Tentative Weekly Lecture Plan
11
Tentative Weekly Lecture Plan
12
Tentative Weekly Lecture Plan
13
Tentative Weekly Lecture Plan
14
Week1
Introduction to Computer
Hardware and Software
Reading:
▪ Chapter 1 of Guttag’s Book
15
What Does A Computer Do?
• A computer does two things only:
1) performs calculations:
▪ A typical computer performs a billion or so calculations per second.
16
What Does A Computer Do?
• What kinds of calculations?
17
What Does A Computer Do?
• For most of human history, computation was limited by
18
Types Of Knowledge
• All knowledge can be thought of as either declarative or imperative
19
Declarative Knowledge
• Composed of statements of fact
• Example:
20
Imperative Knowledge
• It is “how to” knowledge, or recipes for deducing information.
• Example:
21
Recipe For Deducing Square Root Of A
Number
1. Start with a guess, g.
4. Using this new guess, which we again call g, repeat the process
until g*g is close enough to x.
22
Recipe For Deducing Square Root Of A
Number
• Square root of x = 16
23
Recipe For Deducing Square Root Of A
Number
• Square root of x = 16
24
Recipe For Deducing Square Root Of A
Number
• Square root of x = 16
25
Recipe For Deducing Square Root Of A
Number
• Square root of x = 16
26
Recipe For Deducing Square Root Of A
Number
• Square root of x = 16
27
What is A Recipe?
• a sequence of simple steps
• a flow of control that specifies when each step is to be executed
• a means of determining when to stop
• Recipe is called an algorithm
28
Recipe For Deducing Square Root Of A
Number
1. Start with a guess, g.
4. Using this new guess, which we again call g, repeat the process
until g*g is close enough to x.
29
Recipe For Deducing Square Root Of A
Number
1. Start with a guess, g.
4. Using this new guess, which we again call g, repeat the process
until g*g is close enough to x.
30
Recipe For Deducing Square Root Of A
Number
1. Start with a guess, g.
4. Using this new guess, which we again call g, repeat the process
until g*g is close enough to x.
31
What is An Algorithm?
• A finite list of instructions describing a set of computations that
32
An Algorithm is Like A Recipe From A
Cookbook
1. Put custard mixture over heat.
2. Stir.
5. If clear path is left, remove custard from heat and let cool.
6. Otherwise repeat.
33
Computers are Machines
• How to capture the idea of a recipe in a mechanical process?
• Approaches:
▪ Fixed-program computers
▪ Stored-program computers
34
Fixed-Program Computers
• They were designed to do very specific things
• The earliest computing machines
• Examples:
▪ Alan Turing’s bombe machine
− Developed during World War II
− was designed for the purpose of breaking German Enigma codes
▪ A handheld calculator
− can do basic arithmetic
− cannot be used as a word processor
35
Stored-Program Computers
• The first truly modern computer was the Manchester Mark 1.
36
Basic Machine Architecture
37
Stored-Program Computers
• The heart of such a computer is an interpreter that can execute any legal
set of instructions
38
Stored-Program Computers
• Both the program and the data it manipulates reside in memory.
39
Stored-Program Computers
• Most often, the interpreter simply executes the next instruction in the
sequence.
• In some cases, it performs a test, and based on that test, execution may
jump to another point in the sequence of instructions.
▪ This is called flow of control.
40
Flowchart – a Depiction of a Flow of
Control
• a rectangular box depicts a
processing step
41
Basic Primitives
• The British mathematician Alan Turing showed that you can compute
anything using 6 primitives.
42
Creating Recipes
• To create recipes, or sequences of instructions, we need a
programming language.
43
Programming Languages
• Hundreds of programming languages in the world but no best language
44
Aspects of Languages
• Each language has a set of primitive constructs, a syntax, a static
semantics, and a semantics.
• Primitive constructs:
▪ English:
− words
45
Aspects of Languages
• Each language has a set of primitive constructs, a syntax, a static
semantics, and a semantics.
• Primitive constructs:
▪ A programming language:
− literals (e.g., the number 3.2 and the string 'abc’)
− infix operators (e.g., + and /).)
46
Aspects of Languages
47
Aspects of Languages
• The syntax of a language defines which strings of characters and symbols
are well formed.
• English:
▪ the string “Cat dog boy.” is not a syntactically valid sentence
▪ the syntax of English does not accept sentences of the form <noun> <noun>
<noun>.
48
Aspects of Languages
• The syntax of a language defines which strings of characters and
symbols are well formed.
• Python:
▪ the sequence of primitives 3.2 + 3.2 is syntactically well formed, but the
sequence 3.2 3.2 is not.
49
Aspects of Languages
• The static semantics defines which syntactically valid strings have a
meaning.
• English:
▪ the string “I runs quickly,” is of the form <pronoun> < verb> <adverb>,
▪ It is a syntactically acceptable sequence.
▪ It is not valid, because “I” is singular, and the verb “runs” is plural.
50
Aspects of Languages
• The static semantics defines which syntactically valid strings have a
meaning.
• Python:
▪ the sequence 3.2/'abc’
▪ It is syntactically well formed (<literal> <operator> <literal>),
▪ but produces a static semantic error since it is not meaningful to divide a
number by a string of characters.
51
Aspects of Languages
• The semantics associates a meaning with each syntactically correct string
of symbols that has no static semantic errors.
52
Aspects of Languages
• The semantics is the meaning with each syntactically correct string of
symbols that has no static semantic errors.
• Programming languages:
▪ have only one meaning but may not be what programmer intended
53
Where Things Go Wrong
• syntactic errors:
▪ most common kind of error but least dangerous and are easily caught
54
Where Things Go Wrong
• no semantic errors but different meaning than what programmer
intended
▪ program crashes, stops running
▪ program runs forever
▪ program gives an answer but different than expected
55