You are on page 1of 47

ECSE101L- Computational Thinking Using

Python
Introduction

Anirban Bhar
(Anirban.Bhar@bennett.edu.in)

Department of Computer Science and Engineering, Bennett University, Greater


Noida, Uttarpradesh, India

A. Bhar ECSE101L- Computational Thinking Using Python


Outline

1 Algorithm

2 Flowchart

3 Programming Language

A. Bhar ECSE101L- Computational Thinking Using Python


Algorithm: Introduction to Computer Science
Man, Cabbage, Goat, Wolf
Problem
A man wishes to bring a
cabbage, a goat and a wolf
from east side of a river to
the west side of the river.

A. Bhar ECSE101L- Computational Thinking Using Python


Algorithm: Introduction to Computer Science
Man, Cabbage, Goat, Wolf
Problem
A man wishes to bring a
cabbage, a goat and a wolf
from east side of a river to
the west side of the river.
His boat is big enough to
hold himself and either the
cabbage, goat or wolf.

A. Bhar ECSE101L- Computational Thinking Using Python


Algorithm: Introduction to Computer Science
Man, Cabbage, Goat, Wolf
Problem
A man wishes to bring a
cabbage, a goat and a wolf
from east side of a river to
the west side of the river.
His boat is big enough to
hold himself and either the
cabbage, goat or wolf.
The man can not leave the
goat alone with the
cabbage.

A. Bhar ECSE101L- Computational Thinking Using Python


Algorithm: Introduction to Computer Science
Man, Cabbage, Goat, Wolf
Problem
A man wishes to bring a
cabbage, a goat and a wolf
from east side of a river to
the west side of the river.
His boat is big enough to
hold himself and either the
cabbage, goat or wolf.
The man can not leave the
goat alone with the
cabbage.
The man can not leave the
wolf alone with the goat.

A. Bhar ECSE101L- Computational Thinking Using Python


Algorithm: Introduction to Computer Science
Man, Cabbage, Goat, Wolf
Problem
A man wishes to bring a
cabbage, a goat and a wolf
from east side of a river to
the west side of the river.
His boat is big enough to
hold himself and either the
cabbage, goat or wolf.
The man can not leave the
goat alone with the
cabbage.
The man can not leave the
wolf alone with the goat.
How does the man solve
his problem?
A. Bhar ECSE101L- Computational Thinking Using Python
Algorithm: Introduction to Computer Science

A. Bhar ECSE101L- Computational Thinking Using Python


Algorithm: Introduction to Computer Science

Are the width of the


river, name of the man,
color of the boat
relevant?

A. Bhar ECSE101L- Computational Thinking Using Python


Algorithm: Introduction to Computer Science

Are the width of the


river, name of the man,
color of the boat
relevant?
A representation that
leaves out the details of
what is being represented
is a form of abstraction.

A. Bhar ECSE101L- Computational Thinking Using Python


Algorithm: Introduction to Computer Science

Are the width of the


river, name of the man,
color of the boat
relevant?
A representation that
leaves out the details of
what is being represented
is a form of abstraction.
In order to solve a problem
computationally, we need
representation and a set
of steps that solves the
problem by use of the
representation.

A. Bhar ECSE101L- Computational Thinking Using Python


Algorithm: Introduction to Computer Science

Solutions to Man, Cabbage, Goat, Wolf Problem

A. Bhar ECSE101L- Computational Thinking Using Python


Algorithm: Introduction to Computer Science

Solutions to Man, Cabbage, Goat, Wolf Problem


Are the steps clearly described?

A. Bhar ECSE101L- Computational Thinking Using Python


Algorithm: Introduction to Computer Science

Solutions to Man, Cabbage, Goat, Wolf Problem


Are the steps clearly described?
Are the steps unambiguous?

A. Bhar ECSE101L- Computational Thinking Using Python


Algorithm: Introduction to Computer Science

Solutions to Man, Cabbage, Goat, Wolf Problem


Are the steps clearly described?
Are the steps unambiguous?
Are the steps doable?

A. Bhar ECSE101L- Computational Thinking Using Python


Algorithm: Introduction to Computer Science

Solutions to Man, Cabbage, Goat, Wolf Problem


Are the steps clearly described?
Are the steps unambiguous?
Are the steps doable?
Does following these steps help us to produce a desired result
for given input in a finite amount of time?

A. Bhar ECSE101L- Computational Thinking Using Python


Algorithm: Introduction to Computer Science

Algorithm

A. Bhar ECSE101L- Computational Thinking Using Python


Algorithm: Introduction to Computer Science

Algorithm
It is a finite number of clearly described, unambiguous
doable steps that can be systematically followed to produce a
desired result for given input in a finite amount of time.

A. Bhar ECSE101L- Computational Thinking Using Python


Algorithm: Introduction to Computer Science

Algorithm
It is a finite number of clearly described, unambiguous
doable steps that can be systematically followed to produce a
desired result for given input in a finite amount of time.
An algorithm that correctly solves a given problem must solve
the problem in a reasonable amount of time, otherwise it is of
limited practical use.

A. Bhar ECSE101L- Computational Thinking Using Python


Algorithm: Introduction to Computer Science

A. Bhar ECSE101L- Computational Thinking Using Python


Algorithm: Introduction to Computer Science

A. Bhar ECSE101L- Computational Thinking Using Python


Flowchart: Introduction to Computer Science

Flowchart
It is a diagrammatic representation of an algorithm.

A. Bhar ECSE101L- Computational Thinking Using Python


Flowchart: Introduction to Computer Science
Symbols used in flow-chart

A. Bhar ECSE101L- Computational Thinking Using Python


Flowchart: Introduction to Computer Science

Problem 1: Draw a flowchart to add two numbers entered by the


user.
Problem 2: Draw a flowchart to print 1 to 20

A. Bhar ECSE101L- Computational Thinking Using Python


Programming Language: Introduction to Computer Science

Natural language vs Formal Language

A. Bhar ECSE101L- Computational Thinking Using Python


Programming Language: Introduction to Computer Science

Natural language vs Formal Language


Natural language: Example: Spanish, English, etc.

A. Bhar ECSE101L- Computational Thinking Using Python


Programming Language: Introduction to Computer Science

Natural language vs Formal Language


Natural language: Example: Spanish, English, etc.
Formal language: Example: Notations used by
mathematicians, Representation of chemical structure and
molecules used by chemists, Programming language, etc.

A. Bhar ECSE101L- Computational Thinking Using Python


Programming Language: Introduction to Computer Science

Syntax: A set of characters and the acceptable sequences of


those characters.

A. Bhar ECSE101L- Computational Thinking Using Python


Programming Language: Introduction to Computer Science

Syntax: A set of characters and the acceptable sequences of


those characters.
Example 1: ”How are you?” - Syntactically correct.

A. Bhar ECSE101L- Computational Thinking Using Python


Programming Language: Introduction to Computer Science

Syntax: A set of characters and the acceptable sequences of


those characters.
Example 1: ”How are you?” - Syntactically correct.
Example 2: ”Hoa are you?” - Syntactically incorrect.

A. Bhar ECSE101L- Computational Thinking Using Python


Programming Language: Introduction to Computer Science

Syntax: A set of characters and the acceptable sequences of


those characters.
Example 1: ”How are you?” - Syntactically correct.
Example 2: ”Hoa are you?” - Syntactically incorrect.
Semantics: Meaning associated with each syntactically
correct sequence of characters.

A. Bhar ECSE101L- Computational Thinking Using Python


Programming Language: Introduction to Computer Science

Syntax: A set of characters and the acceptable sequences of


those characters.
Example 1: ”How are you?” - Syntactically correct.
Example 2: ”Hoa are you?” - Syntactically incorrect.
Semantics: Meaning associated with each syntactically
correct sequence of characters.
Example 1: ”Colorless green ideas sleep furiously” -
composed by Noam Chomsky.

A. Bhar ECSE101L- Computational Thinking Using Python


Programming Language: Introduction to Computer Science

Syntax: A set of characters and the acceptable sequences of


those characters.
Example 1: ”How are you?” - Syntactically correct.
Example 2: ”Hoa are you?” - Syntactically incorrect.
Semantics: Meaning associated with each syntactically
correct sequence of characters.
Example 1: ”Colorless green ideas sleep furiously” -
composed by Noam Chomsky.
The above sentence is syntactically correct, but semantically
incorrect.

A. Bhar ECSE101L- Computational Thinking Using Python


Programming Language: Introduction to Computer Science

Programming language:

A. Bhar ECSE101L- Computational Thinking Using Python


Programming Language: Introduction to Computer Science

Programming language:
High-level language: Example: C, C++, Java, Python, etc.

A. Bhar ECSE101L- Computational Thinking Using Python


Programming Language: Introduction to Computer Science

Programming language:
High-level language: Example: C, C++, Java, Python, etc.
Advantages: Easier to write, Portable.

A. Bhar ECSE101L- Computational Thinking Using Python


Programming Language: Introduction to Computer Science

Programming language:
High-level language: Example: C, C++, Java, Python, etc.
Advantages: Easier to write, Portable.
Low-level language: Sometimes referred to as machine
language or assembly language.

A. Bhar ECSE101L- Computational Thinking Using Python


Programming Language: Introduction to Computer Science

Programming language:
High-level language: Example: C, C++, Java, Python, etc.
Advantages: Easier to write, Portable.
Low-level language: Sometimes referred to as machine
language or assembly language.
Disadvantages: Not portable.

A. Bhar ECSE101L- Computational Thinking Using Python


Programming Language: Introduction to Computer Science

High-level language to Low-level language:

A. Bhar ECSE101L- Computational Thinking Using Python


Programming Language: Introduction to Computer Science

High-level language to Low-level language:


Compiler

A. Bhar ECSE101L- Computational Thinking Using Python


Programming Language: Introduction to Computer Science

High-level language to Low-level language:


Compiler
Interpreter

A. Bhar ECSE101L- Computational Thinking Using Python


Programming Language: Introduction to Computer Science

High-level language to Low-level language:


Compiler
Interpreter
Example of Interpreted language is Python.

A. Bhar ECSE101L- Computational Thinking Using Python


Programming Language: Introduction to Computer Science

Program
A program is a sequence of instructions that specifies how to
perform a computation.

A. Bhar ECSE101L- Computational Thinking Using Python


Programming Language: Introduction to Computer Science

Debugging

A. Bhar ECSE101L- Computational Thinking Using Python


Programming Language: Introduction to Computer Science

Debugging
Programming errors are called bugs.

A. Bhar ECSE101L- Computational Thinking Using Python


Programming Language: Introduction to Computer Science

Debugging
Programming errors are called bugs.
The process of tracking them down and correcting them is
called debugging.

A. Bhar ECSE101L- Computational Thinking Using Python


Programming Language: Introduction to Computer Science

Debugging
Programming errors are called bugs.
The process of tracking them down and correcting them is
called debugging.
Three kinds of errors can occur in a program: syntax errors,
runtime errors and semantic errors.

A. Bhar ECSE101L- Computational Thinking Using Python

You might also like