0% found this document useful (0 votes)
2 views55 pages

Week 1

The document outlines the course EE132, Introduction to Computing and Data Science, taught by Professor Kashif Javed, including logistics, grading policy, course content, and recommended books. It emphasizes the importance of practice in programming and covers foundational topics such as algorithms, programming languages, and types of knowledge. The course has no prerequisites and aims to provide a rigorous introduction to computer programming with applications in data science.

Uploaded by

2023ee72
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views55 pages

Week 1

The document outlines the course EE132, Introduction to Computing and Data Science, taught by Professor Kashif Javed, including logistics, grading policy, course content, and recommended books. It emphasizes the importance of practice in programming and covers foundational topics such as algorithms, programming languages, and types of knowledge. The course has no prerequisites and aims to provide a rigorous introduction to computer programming with applications in data science.

Uploaded by

2023ee72
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

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%

• 2 Quizzes: 2 x 10% = 20%

• 1 Midterm exam: 30%

• 1 Final exam: 40%

4
About the Course
• This course serves as a rigorous introduction to computer programming.

• Apart from standard introductory topics, it touches upon


▪ Debugging,

▪ Object-oriented design,

▪ Program complexity,

▪ Applications of programming to data science

5
About the Course
• New to programming? PRACTICE. PRACTICE? PRACTICE!

• can’t passively absorb programming as a skill

• download code before lecture and follow along

• don’t be afraid to try out Python commands!

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

• Ana Bell, Get Programming Learn to code with Python, Manning


Publications, 2018

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.

2) remembers the results of those calculations:


▪ A small computer might have hundreds of gigabytes of storage.

16
What Does A Computer Do?
• What kinds of calculations?

1) built-into the language

2) ones that you define as the programmer

• computers only know what you tell them

17
What Does A Computer Do?
• For most of human history, computation was limited by

▪ the speed of calculation of the human brain

▪ the ability to record computational results with the human hand

18
Types Of Knowledge
• All knowledge can be thought of as either declarative or imperative

19
Declarative Knowledge
• Composed of statements of fact

• Example:

▪ “the square root of x is a number y such that y * y = x.”


▪ “it is possible to travel by train from Paris to Rome.”

• Doesn’t tell us anything about how to find a square root.

20
Imperative Knowledge
• It is “how to” knowledge, or recipes for deducing information.

• Example:

▪ A Greek mathematician (Heron of Alexandria) was the first to document a way


to compute the square root of a number.

▪ His method can be summarized as:

21
Recipe For Deducing Square Root Of A
Number
1. Start with a guess, g.

2. If g*g is close enough to x, stop and say that g is the answer.

3. Otherwise create a new guess by averaging g and x/g, i.e., (g +


x/g)/2.

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

• Another Example: 1+2+3 = an algorithm!

28
Recipe For Deducing Square Root Of A
Number
1. Start with a guess, g.

2. If g*g is close enough to x, stop and say that g is the answer.

3. Otherwise create a new guess by averaging g and x/g, i.e., (g +


x/g)/2.

4. Using this new guess, which we again call g, repeat the process
until g*g is close enough to x.

Can you identify the sequence of steps?

29
Recipe For Deducing Square Root Of A
Number
1. Start with a guess, g.

2. If g*g is close enough to x, stop and say that g is the answer.

3. Otherwise create a new guess by averaging g and x/g, i.e., (g +


x/g)/2.

4. Using this new guess, which we again call g, repeat the process
until g*g is close enough to x.

Can you identify the flow control?

30
Recipe For Deducing Square Root Of A
Number
1. Start with a guess, g.

2. If g*g is close enough to x, stop and say that g is the answer.

3. Otherwise create a new guess by averaging g and x/g, i.e., (g +


x/g)/2.

4. Using this new guess, which we again call g, repeat the process
until g*g is close enough to x.

Can you identify the means of determining when to stop?

31
What is An Algorithm?
• A finite list of instructions describing a set of computations that

▪ when executed on a set of inputs will proceed through a sequence of well-


defined states

▪ eventually produce an output

32
An Algorithm is Like A Recipe From A
Cookbook
1. Put custard mixture over heat.

2. Stir.

3. Dip spoon in custard.

4. Remove spoon and run finger across back of spoon.

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.

• Such a computer stores (and manipulates) a sequence of instructions and


has components that will execute any instruction in that sequence.

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

• A sequence of instructions stored inside computer


▪ built from predefined set of primitive instructions
1) arithmetic and logic
2) simple tests
3) moving data

38
Stored-Program Computers
• Both the program and the data it manipulates reside in memory.

• There is a program counter


▪ points to a particular location in memory,
▪ computation starts by executing the instruction at that point.

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

• a diamond box depicts a test

• arrows indicate the order in


which things are done

41
Basic Primitives
• The British mathematician Alan Turing showed that you can compute
anything using 6 primitives.

• All modern programming languages have more convenient set of


primitives.

• We can abstract methods to create new primitives.

• Anything computable in one language is computable in any other


programming language.

42
Creating Recipes
• To create recipes, or sequences of instructions, we need a
programming language.

• A programming language provides a set of primitive operations

• Expressions are complex but legal combinations of primitives in a


programming language

• Expressions and computations have values and meanings in a


programming language

43
Programming Languages
• Hundreds of programming languages in the world but no best language

• Different languages are better or worse for different kinds of applications.


▪ MATLAB is a good language for manipulating vectors and matrices.
▪ C is a good language for writing programs that control data networks.
▪ PHP is a good language for building Web sites.
▪ Python is a good general-purpose 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>.

▪ "cat hugs boy" → syntactically valid

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.

▪ “hi” 5 → not syntactically valid

▪ 3.2*5 → syntactically valid

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.

▪ "I are hungry" → syntactically valid

▪ These are examples of static semantic error

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.

▪ 3+”hi" → static semantic error

51
Aspects of Languages
• The semantics associates a meaning with each syntactically correct string
of symbols that has no static semantic errors.

• In natural languages, the semantics of a sentence can be ambiguous and


can have many meanings

▪ “I cannot praise this student too highly” (criticizing or flattering?)

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

• static semantic errors:


▪ some languages check for these before running program.
▪ These can cause unpredictable behavior

• If a program has no syntactic errors and no static semantic errors, it has a


meaning (semantics).

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

You might also like