Computer Programming
Introduction to Computer Programming in
Python
Lecture 1 & 2
1
COURSE DESCRIPTION
• This course offers an introduction to computer programming via the
Python programming language to students with little or no programming
experience.
• Students concentration to explanation-demonstrations and gain (ideally
simultaneous) practical experience with basic coding concepts.
• The students will develop skills to program and use computational
techniques to solve problems.
• Topics include the notion of computation, Python, algorithms for
iterations and functions, different data types, testing and debugging,
class and inheritance, algorithmic complexity, plotting, file I/O and
processing.
COURSE OBJECTIVES
To train the students with the structure and
operations in programming along with latest tools and
their applications.
COURSE LEARNING OUTCOMES
S# CLO Learning Taxonomy PLO
Domain Level
1 Explain the role of computation and Cognitive 2 1
importance of programming.
2 Reproduce, write, debug and dry
run/execute computer programs. Cognitive 3 1
3 Develop an algorithm and
Implement programs in python to Cognitive 3 3
represent solution to a problem, so
that they can excel in subjects with
programming components.
Introduction to Computer Programming in
Python
1
Why learn programming ?
WHAT DOES A COMPUTER DO
§ Fundamentally:
◦ performs calculations
a billion calculations per second!
◦ remembers results
100s of gigabytes of storage!
§ What kinds of calculations?
◦ built-in to the language
◦ ones that you define as the programmer
§ computers only know what you tell them
1
COMPUTERS ARE MACHINES
§ how to capture a recipe in a mechanical process
§ fixed program computer
◦ calculator
§ stored program computer
◦ machine stores and executes instructions
17
STORED PROGRAM COMPUTER
q Sequence of instructions stored inside computer
built from predefined set of primitive instructions
1) arithmetic and logic
2) simple tests
3) moving data
q Special program (interpreter) executes each
instruction in order
◦ use tests to change flow of control through sequence
◦ stop when done
Computing &
Computers History
Evolution of Computing
THE WORLD OF COMPUTERS
Earliest computing device “ABACUS” circa 2500 BCE Easier à Faster à Accurate
The word ‘computer’ first used in 1600s by Richard Braithwait
Until 1800s the meaning started shifted to devices
German polymath Leibniz made ‘Step Reckone’
Analytical Engine is the successor of Difference Engine and first “General Purpose Computer”
Ada Lovelace regarded as the first programmer for writing hypothetical programs in 1800s.
The Great War and Computers
BY ALAN TURING involving mathematical logic by George Boole
The Silicon Age and Integrated Circuits
MODERN COMPUTERS
MODERN COMPUTERS
John Von Neuman contributed in Nuclear Tests with Oppenheimer but decided to invent
something even better than “BOMBS”
Computer Hardware
Output
CPU Devices
Input
Devices
Main Secondary
Memory Memory
Hardware Components
Programming
Computer Software
• Software consists of programs and enables a computer to
perform specific tasks, as opposed to its physical components
(hardware) which can only do the tasks they are mechanically
designed for.
• It is loaded into a computer's storage (such as a hard drive, a
memory, or RAM). Once the software is loaded, the computer
is able to execute the software in the Central Processing Unit
(CPU).
Computer Programs: Programming Languages
• A program or a code is just a sequence of instructions telling the
computer what to do
• Obviously, we need to provide these instructions in a language that
computers can understand
• Every structure in a programming language has an exact form (i.e., syntax)
and a precise meaning (i.e., semantic)
• Each has strengths and weaknesses and specializations (just like human
languages)
• High-level (closer to how humans think) vs. low-level (closer to
computers, but much faster)
Types of Programming Languages
• Compiled
• "Source code" (what the programmer
writes) is converted to "object code"
(what the computer reads)
• Compiled once, run many times (like
translating a book to another
language)
• Interpreted
• Machine code instructions generated
on the fly (like acting as a verbal
translator in a conversation)
• Slower to run, but no compile step!
Programming Language
Source Codes
• The "source code" of the program, written in a programming
language
• The source code defines the behavior of the program
• A human can read and edit the source code
Machine Codes
• But source code does not "run" on the CPU directly
• The CPU understands machine code
• Only machine code can actually run on the CPU
• The source code is translated to machine code, and that
translation runs on the CPU
Interpreter Vs Compiler : Difference
Between Interpreter and Compiler
• We generally write a computer program using high-level
language.
• A high-level language is one which is understandable by us
humans. It contains words and phrases from the English (or other)
language.
• Computer does not understand high-level language. It only
understands program written in 0’s and 1’s in binary, called the
machine code.
• A program written in high-level language is called source code.
• We need to convert the source code into machine code and this is
accomplished by compilers and interpreters. Hence, a compiler or
an interpreter is a program that converts program written in high-
level language into machine code understood by the computer.
Interpreter Vs Compiler: Difference
Between Interpreter and Compiler
Interpreter Vs Compiler : Difference
Between Interpreter and Compiler
BASIC PRIMITIVES
Turing showed that you can compute anything using 6
primitives
Right, Left, Print, Scan, Erase, Nothing/halt
- Modern programming languages have more convenient
set of primitives
- Anything computable in one language is computable in
any other programming language
ASPECTS OF LANGUAGE
• Each programming language has a set of
I. primitive constructs
II. Syntax
III. Static semantics
IV. semantics
• By analogy with a natural language, e.g., English,
the primitive constructs are words.
• The syntax describes which strings of words
constitute well-formed sentences
• The static semantics defines which sentences
are meaningful
• The semantics defines the meaning of those
sentences
ASPECTS OF LANGUAGE
ASPECTS OF LANGUAGE
ASPECTS OF LANGUAGE
WHERE THINGS GO WRONG
PYTHON PROGRAMS
Integrated Development Environment (IDE)
for Python
https://www.anaconda.com/
Integrated Development Environment (IDE)
for Python
Integrated Development Environment (IDE)
for Python