SlideShare a Scribd company logo
Programming Principles
CMP 2421
Programming Principles
Four lectures a week for 14 weeks
Class: 12h30, Tuesday
12h30, Wednesday
09h30-11h25, Friday
Practical session: Thursday 16h30
Test: 2 minimum, assignment, presentation, Quiz
 Ms. Ntinda M.N
 Assistance: Mathe and Paulus
 Light talks (5 min max)
 Install:
 Windows OS
 Python 3….
 gedit
Day1
Is to teach you to think like a
computer Scientist
This way of thinking combines
some of the best features of
mathematics, engineering and
natural science
Goal
 Like Mathematicians, Computer scientists use formal
languages to denote ideas(Specifically computation)
 Like Engineers, they design things, assembling
components into systems and evaluating tradeoffs
among alternatives
 Like Scientists, they observe the behavior of complex
systems, form hypotheses and test predictions
Goal
Natural Language Formal Language
Full of ambiguity which people deal with
by using contextual clues and other
information
Designed to be nearly or completely
unambiguous, which means that any
statement has exactly one meaning,
regardless of context
In order to make up for ambiguity and
reduce misunderstanding, natural
languages employ lots of redundancy
Less redundant and more concise
Literalness are full of idiom and
metaphor
Mean exactly what they say
Natural language vs Formal
Language
 The single most important skill for a computer
Scientist is problem solving
Goal
 The ability to formulate problems, think creatively
about solutions and express a solution clearly and
accurately.
 The process of learning to program is an excellent
opportunity to practice problem solving skills
Problem Solving means:
 Is an artificial language used to write instructions that can
be translated into machine language and then executed by
a computer. Examples:
 Python
 Visual basics
 Java
 C#
 C++
 Pearl
What is a programming Language
 The programming Language you will be learning in
this course is Python
 Python is an example of a high level programming
language.
 Other High level programming languages:
 C,C++,Perl and Java
Programming Language
 There are also low-level programming languages,
sometimes referred to as “machine Languages” or
“Assembly languages”
 Example of low level programming Languages:
 Machine language and Assembly language
Programming Languages
Programming Languages
 High level enable a programmer to
write programs that are more or less independent of
a particular type of computer.
 Such languages are considered high-level because
they are closer to human languages and further
from machine languages.
 In contrast, assembly languages are considered low-
level because they are very close to machine
languages.
Define: High level language, Low
level languages
 Computers can only execute programs written in low
level languages.
 Programs written in high level language have to be
processed before they can run.
 This extra processing takes some time, which is a
small disadvantage of high level languages.
 A related meaning "to execute" refers to the specific
action of a user starting (or launching or invoking) a
program, as in "Please run the ... application.“
“RUN”
High level Low level
It is much easier to program Difficult to program
Takes less time to write, shorter
and easier to read and more likely
to be correct
Take longer to write and not easy
to read
Portable(they can run on
different kinds of computers with
or no modifications)
Low level programs can run on
only one kind of computer and
have to be rewritten to run on
another
High level vs low level languages
 Two kinds of programs process high-level languages
into low-level languages:
 Interpreters and Compilers
High-level program languages
 A compiler reads the program and translate it
completely before the program starts running.
Compiler
Compiler Object code
Executor Output
 In this case, a high-level language is called, a source
code and the translated program is called the object
code or the executable.
 Once a program is compiled, you can execute it
repeatedly without further translation
Compiler continue……
 An interpreter reads a high-level program and
executes it, meaning that it does what the program
says, it processes the program a little at a time,
alternatively reading times and performing
computations
Interpreter
OutputInterpreter
Source
Code
 Python is considered to be an interpreted language
because python programs are executed by an
interpreter
Interpreter
 A program is a sequence of instructions that specifies
how to perform a computation.
 The computation might be something mathematical
such as solving a system of equations or finding the
roots of a polynomial, but it can also be a symbolic
computation such as searching and replacing text in a
document
What Is a program?
 Input: get data from the keyboard, a file or some
other device
 Output: Display data on the screen or send data to a
file or other device
 Math: perform basic mathematical operations like
addition and multiplication
 Conditional execution:
 Check for certain condition and execute the appropriate
sequence of statement.
 Perform some repeatedly, usually with some variation
Every program you have ever used is
made up of the following
instructions:
 Programming is the process of breaking a large
complex task into smaller and smaller subtasks until
the subtasks are simple enough to be performed with
one of these basic instructions.
What is programming
 Programming is a complex process, and because it is
done by human beings, it often leads to errors.
 Python can only execute a program if the program is
syntactically correct otherwise the process fails and
returns an error message.
 Three kinds of errors
 Runtime errors
 Syntax errors
 Semantic errors
What is debugging
 Syntax refers to the structure of a program and the
rules about that structure.
 Example:
 In English, a sentence must begin with a capital letter
and end with a period.
 In English, you can be forgiven when you have a
grammatical error.
 Python is not forgiving
Syntax errors
 If there is a single error anywhere in your program,
python will print an error message and quit, and you
will not be able to run your program
 Learn your Syntax
 Beginners spend more time tracking errors, make use
of Google……with experience, you will make few
errors and track them down easier
Syntax errors cont……
 Runtime errors does not appear until you run the
program.
 These errors are also called exceptions because they
usually indicate that something exceptional(and bad)
has happened.
 Runtime errors are rare in the simple programs, you
will see in the first few examples you might not
encounter one
Runtime errors
 Occurs when the program run successfully, in the
sense that the computer will not generate any error
messages but it will not do the right thing.
 The program will do something else.
Semantic errors
 Example:
 We want to add 5+10 = 15 instead we add 3+10 = 13. 
 Identifying semantic errors can be tricky because it
requires you to work backward by looking at the
output of the program and trying to figure out what it
is doing
Semantic errors cont….
 Know how to debug
 For some people, debugging and programming is the
same thing.
 Programming is the process of gradually debugging a
program until it does what you want.
Debugging
 Command-line mode and script mode
 In command-line mode, you type python programs
and the interpreter prints the results
 In a script mode, you can write a program in a file and
use the interpreter to execute the contents of the
file. Such a file is called a script.
 Use a text editor to crate a file.
 As with MsWord file .doc,,,,,,,,python files end with
.py
There are two ways to use an
interpreter:
 Python is a very popular programming language that
can be used for creating websites, games, scientific
software, graphics
 Python originated in the late 1980s and its main goal
is to be readable by human beings (not only
machines!).
Python
 https://www.python.org/downloads/
 make sure you scroll down and choose the "Add
python.exe to the Path" option, as
 shown here:
 Type python in cmd to
 Confirm it was
 successfully installed
Download Python for Windows
from the website
 Gedit is an open-source, free editor, available for all
operating systems.
 http://ftp.gnome.org/pub/GNOME/binaries/win32/gedi
t/2.30/
 Why are we installing a code editor?
 Code needs to be plain text
 Problem with programs like Word and Textedit is that
they don't actually produce plain text, they produce rich
text (with fonts and formatting)
 Code editors provide helpful features, like highlighting
code with colour according to its meaning, or
Code editor: gedit
 command line or command-line interface
 is a text-based application for viewing, handling, and
manipulating files on your computer.
 Other names for the command line are:
cmd,CLI, prompt, console or terminal.
 Open the command-line interface
 Windows
 Go to Start menu → All Programs → Accessories →
Command Prompt.
 Prompt
 On Windows, it's a > sign, like this: command-line >
Introduction to the command-line
interface
 Current directory (know where we are)
 > cd
 C:Usersnntinda.UNAM.000
 List files and directories (what's in it?)
 > dir
 Directory of C:Usersnntinda.UNAM.000
 05/06/2015 07:28 PM <DIR> Applications
 05/06/2015 07:28 PM <DIR> Desktop
 05/06/2015 07:28 PM <DIR> Downloads
 05/06/2015 07:28 PM <DIR> Music ...
Basics: Each operating system has a slightly
different set of commands for the command
line
 Change current directory (let's go to Desktop directory)
 > cd Desktop
 PRO tip:
 if you type cd D and then hit tab on your keyboard,
the command line will automatically autofill the
rest of the name so you can navigate faster. If
there is more than one folder starting with "D", hit
the tab button twice to get a list of options.
Basics: Each operating system has a slightly
different set of commands for the command
line
 Create directory (folder) title: helloWorld
 > mkdir helloWorld
 PRO tip:
 If you don't want to type the same commands over and
over, try pressing the up arrow and down arrow on your
keyboard to cycle through recently used commands.
Basics: Each operating system has a slightly
different set of commands for the command
line
• Create a folder on your desktop called firstYearDiploma
• In your newly created firstYearDiploma directory create a
directory called name,20150999(student number).
Exercise

More Related Content

PPTX
Principles of programming
PDF
Introduction to Computer Programming
PPT
Introduction to programming principles languages
PPTX
Programming languages and paradigms
PPTX
Algorithms - Introduction to computer programming
PPTX
Basic programming concepts
PPT
13 A Programing Languages (IT) Lecture Slide
PPT
Programming Languages An Intro
Principles of programming
Introduction to Computer Programming
Introduction to programming principles languages
Programming languages and paradigms
Algorithms - Introduction to computer programming
Basic programming concepts
13 A Programing Languages (IT) Lecture Slide
Programming Languages An Intro

What's hot (20)

PPTX
Ch1 language design issue
PPTX
Logical programming languages and functional programming languages
PPT
The Programmer Life Cycle
PPTX
PPT
Evolution and History of Programming Languages - Software/Hardware/System
PDF
Programming languages and concepts by vivek parihar
DOC
Notacd07
PPTX
Software programming and development
PDF
Programing language
PPT
An overview of computers and programming languages
PPTX
Introduction to programming
DOCX
ICT, Importance of programming and programming languages
PDF
Principles of programming languages. Detail notes
PPTX
Introduction to computer programming
PPTX
introduction to programming languages
PPT
Programming languages
PDF
Principles of-programming-languages-lecture-notes-
PDF
Computer programming programming_langugages
PPT
Programming language design and implemenation
Ch1 language design issue
Logical programming languages and functional programming languages
The Programmer Life Cycle
Evolution and History of Programming Languages - Software/Hardware/System
Programming languages and concepts by vivek parihar
Notacd07
Software programming and development
Programing language
An overview of computers and programming languages
Introduction to programming
ICT, Importance of programming and programming languages
Principles of programming languages. Detail notes
Introduction to computer programming
introduction to programming languages
Programming languages
Principles of-programming-languages-lecture-notes-
Computer programming programming_langugages
Programming language design and implemenation
Ad

Similar to Cmp2412 programming principles (20)

PPT
Introduction to python
PPTX
Module1-Chapter1_ppt.pptx
PPTX
Python Lecture 1
PDF
ProgFund_Lecture_1_Introduction_to_Programming.pdf
PPTX
Introduction_to_Programming.pptx
PPTX
PCEP Module 1.pptx
PPTX
Python Intro Slides for Students CSC-148 Chapter 1
PDF
Introduction to Python and its basics.pdf
PDF
Introduction to Python - Algorithm Compiler
PPTX
UNIT-1 : 20ACS04 – PROBLEM SOLVING AND PROGRAMMING USING PYTHON
PPTX
Introduction to python
PDF
CPPDS Slide.pdf
PDF
Learn to Code with MIT App Inventor ( PDFDrive ).pdf
PPTX
Programming_Languages_Presentation.pptx.
PPTX
An Introduction To Python - Python, Print()
PDF
01. Introduction to Python.pdf yessir sirski
PPTX
Lecture-1-Introduction-Sep02-2018 (1).pptx
PPTX
Introduction to computers and programming languages
PPT
introduction to computer programming CPPL1.ppt
PPT
Help with Pyhon Programming Homework
Introduction to python
Module1-Chapter1_ppt.pptx
Python Lecture 1
ProgFund_Lecture_1_Introduction_to_Programming.pdf
Introduction_to_Programming.pptx
PCEP Module 1.pptx
Python Intro Slides for Students CSC-148 Chapter 1
Introduction to Python and its basics.pdf
Introduction to Python - Algorithm Compiler
UNIT-1 : 20ACS04 – PROBLEM SOLVING AND PROGRAMMING USING PYTHON
Introduction to python
CPPDS Slide.pdf
Learn to Code with MIT App Inventor ( PDFDrive ).pdf
Programming_Languages_Presentation.pptx.
An Introduction To Python - Python, Print()
01. Introduction to Python.pdf yessir sirski
Lecture-1-Introduction-Sep02-2018 (1).pptx
Introduction to computers and programming languages
introduction to computer programming CPPL1.ppt
Help with Pyhon Programming Homework
Ad

Recently uploaded (20)

PDF
Classroom Observation Tools for Teachers
PPTX
GDM (1) (1).pptx small presentation for students
PDF
RMMM.pdf make it easy to upload and study
PPTX
Pharma ospi slides which help in ospi learning
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Complications of Minimal Access Surgery at WLH
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Basic Mud Logging Guide for educational purpose
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
VCE English Exam - Section C Student Revision Booklet
Classroom Observation Tools for Teachers
GDM (1) (1).pptx small presentation for students
RMMM.pdf make it easy to upload and study
Pharma ospi slides which help in ospi learning
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Complications of Minimal Access Surgery at WLH
Final Presentation General Medicine 03-08-2024.pptx
Basic Mud Logging Guide for educational purpose
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
TR - Agricultural Crops Production NC III.pdf
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
Microbial disease of the cardiovascular and lymphatic systems
O5-L3 Freight Transport Ops (International) V1.pdf
Supply Chain Operations Speaking Notes -ICLT Program
VCE English Exam - Section C Student Revision Booklet

Cmp2412 programming principles

  • 2. Programming Principles Four lectures a week for 14 weeks Class: 12h30, Tuesday 12h30, Wednesday 09h30-11h25, Friday Practical session: Thursday 16h30 Test: 2 minimum, assignment, presentation, Quiz
  • 3.  Ms. Ntinda M.N  Assistance: Mathe and Paulus  Light talks (5 min max)  Install:  Windows OS  Python 3….  gedit Day1
  • 4. Is to teach you to think like a computer Scientist This way of thinking combines some of the best features of mathematics, engineering and natural science Goal
  • 5.  Like Mathematicians, Computer scientists use formal languages to denote ideas(Specifically computation)  Like Engineers, they design things, assembling components into systems and evaluating tradeoffs among alternatives  Like Scientists, they observe the behavior of complex systems, form hypotheses and test predictions Goal
  • 6. Natural Language Formal Language Full of ambiguity which people deal with by using contextual clues and other information Designed to be nearly or completely unambiguous, which means that any statement has exactly one meaning, regardless of context In order to make up for ambiguity and reduce misunderstanding, natural languages employ lots of redundancy Less redundant and more concise Literalness are full of idiom and metaphor Mean exactly what they say Natural language vs Formal Language
  • 7.  The single most important skill for a computer Scientist is problem solving Goal
  • 8.  The ability to formulate problems, think creatively about solutions and express a solution clearly and accurately.  The process of learning to program is an excellent opportunity to practice problem solving skills Problem Solving means:
  • 9.  Is an artificial language used to write instructions that can be translated into machine language and then executed by a computer. Examples:  Python  Visual basics  Java  C#  C++  Pearl What is a programming Language
  • 10.  The programming Language you will be learning in this course is Python  Python is an example of a high level programming language.  Other High level programming languages:  C,C++,Perl and Java Programming Language
  • 11.  There are also low-level programming languages, sometimes referred to as “machine Languages” or “Assembly languages”  Example of low level programming Languages:  Machine language and Assembly language Programming Languages
  • 13.  High level enable a programmer to write programs that are more or less independent of a particular type of computer.  Such languages are considered high-level because they are closer to human languages and further from machine languages.  In contrast, assembly languages are considered low- level because they are very close to machine languages. Define: High level language, Low level languages
  • 14.  Computers can only execute programs written in low level languages.  Programs written in high level language have to be processed before they can run.  This extra processing takes some time, which is a small disadvantage of high level languages.
  • 15.  A related meaning "to execute" refers to the specific action of a user starting (or launching or invoking) a program, as in "Please run the ... application.“ “RUN”
  • 16. High level Low level It is much easier to program Difficult to program Takes less time to write, shorter and easier to read and more likely to be correct Take longer to write and not easy to read Portable(they can run on different kinds of computers with or no modifications) Low level programs can run on only one kind of computer and have to be rewritten to run on another High level vs low level languages
  • 17.  Two kinds of programs process high-level languages into low-level languages:  Interpreters and Compilers High-level program languages
  • 18.  A compiler reads the program and translate it completely before the program starts running. Compiler Compiler Object code Executor Output
  • 19.  In this case, a high-level language is called, a source code and the translated program is called the object code or the executable.  Once a program is compiled, you can execute it repeatedly without further translation Compiler continue……
  • 20.  An interpreter reads a high-level program and executes it, meaning that it does what the program says, it processes the program a little at a time, alternatively reading times and performing computations Interpreter OutputInterpreter Source Code
  • 21.  Python is considered to be an interpreted language because python programs are executed by an interpreter Interpreter
  • 22.  A program is a sequence of instructions that specifies how to perform a computation.  The computation might be something mathematical such as solving a system of equations or finding the roots of a polynomial, but it can also be a symbolic computation such as searching and replacing text in a document What Is a program?
  • 23.  Input: get data from the keyboard, a file or some other device  Output: Display data on the screen or send data to a file or other device  Math: perform basic mathematical operations like addition and multiplication  Conditional execution:  Check for certain condition and execute the appropriate sequence of statement.  Perform some repeatedly, usually with some variation Every program you have ever used is made up of the following instructions:
  • 24.  Programming is the process of breaking a large complex task into smaller and smaller subtasks until the subtasks are simple enough to be performed with one of these basic instructions. What is programming
  • 25.  Programming is a complex process, and because it is done by human beings, it often leads to errors.  Python can only execute a program if the program is syntactically correct otherwise the process fails and returns an error message.  Three kinds of errors  Runtime errors  Syntax errors  Semantic errors What is debugging
  • 26.  Syntax refers to the structure of a program and the rules about that structure.  Example:  In English, a sentence must begin with a capital letter and end with a period.  In English, you can be forgiven when you have a grammatical error.  Python is not forgiving Syntax errors
  • 27.  If there is a single error anywhere in your program, python will print an error message and quit, and you will not be able to run your program  Learn your Syntax  Beginners spend more time tracking errors, make use of Google……with experience, you will make few errors and track them down easier Syntax errors cont……
  • 28.  Runtime errors does not appear until you run the program.  These errors are also called exceptions because they usually indicate that something exceptional(and bad) has happened.  Runtime errors are rare in the simple programs, you will see in the first few examples you might not encounter one Runtime errors
  • 29.  Occurs when the program run successfully, in the sense that the computer will not generate any error messages but it will not do the right thing.  The program will do something else. Semantic errors
  • 30.  Example:  We want to add 5+10 = 15 instead we add 3+10 = 13.   Identifying semantic errors can be tricky because it requires you to work backward by looking at the output of the program and trying to figure out what it is doing Semantic errors cont….
  • 31.  Know how to debug  For some people, debugging and programming is the same thing.  Programming is the process of gradually debugging a program until it does what you want. Debugging
  • 32.  Command-line mode and script mode  In command-line mode, you type python programs and the interpreter prints the results  In a script mode, you can write a program in a file and use the interpreter to execute the contents of the file. Such a file is called a script.  Use a text editor to crate a file.  As with MsWord file .doc,,,,,,,,python files end with .py There are two ways to use an interpreter:
  • 33.  Python is a very popular programming language that can be used for creating websites, games, scientific software, graphics  Python originated in the late 1980s and its main goal is to be readable by human beings (not only machines!). Python
  • 34.  https://www.python.org/downloads/  make sure you scroll down and choose the "Add python.exe to the Path" option, as  shown here:  Type python in cmd to  Confirm it was  successfully installed Download Python for Windows from the website
  • 35.  Gedit is an open-source, free editor, available for all operating systems.  http://ftp.gnome.org/pub/GNOME/binaries/win32/gedi t/2.30/  Why are we installing a code editor?  Code needs to be plain text  Problem with programs like Word and Textedit is that they don't actually produce plain text, they produce rich text (with fonts and formatting)  Code editors provide helpful features, like highlighting code with colour according to its meaning, or Code editor: gedit
  • 36.  command line or command-line interface  is a text-based application for viewing, handling, and manipulating files on your computer.  Other names for the command line are: cmd,CLI, prompt, console or terminal.  Open the command-line interface  Windows  Go to Start menu → All Programs → Accessories → Command Prompt.  Prompt  On Windows, it's a > sign, like this: command-line > Introduction to the command-line interface
  • 37.  Current directory (know where we are)  > cd  C:Usersnntinda.UNAM.000  List files and directories (what's in it?)  > dir  Directory of C:Usersnntinda.UNAM.000  05/06/2015 07:28 PM <DIR> Applications  05/06/2015 07:28 PM <DIR> Desktop  05/06/2015 07:28 PM <DIR> Downloads  05/06/2015 07:28 PM <DIR> Music ... Basics: Each operating system has a slightly different set of commands for the command line
  • 38.  Change current directory (let's go to Desktop directory)  > cd Desktop  PRO tip:  if you type cd D and then hit tab on your keyboard, the command line will automatically autofill the rest of the name so you can navigate faster. If there is more than one folder starting with "D", hit the tab button twice to get a list of options. Basics: Each operating system has a slightly different set of commands for the command line
  • 39.  Create directory (folder) title: helloWorld  > mkdir helloWorld  PRO tip:  If you don't want to type the same commands over and over, try pressing the up arrow and down arrow on your keyboard to cycle through recently used commands. Basics: Each operating system has a slightly different set of commands for the command line
  • 40. • Create a folder on your desktop called firstYearDiploma • In your newly created firstYearDiploma directory create a directory called name,20150999(student number). Exercise