SlideShare a Scribd company logo
1 of 40
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

What's hot

Ch1 language design issue
Ch1 language design issueCh1 language design issue
Ch1 language design issueJigisha Pandya
 
Logical programming languages and functional programming languages
Logical programming languages and functional programming languagesLogical programming languages and functional programming languages
Logical programming languages and functional programming languagesnahianzarif
 
The Programmer Life Cycle
The Programmer Life CycleThe Programmer Life Cycle
The Programmer Life CycleRussell Ovans
 
Programming languages and concepts by vivek parihar
Programming languages and concepts by vivek pariharProgramming languages and concepts by vivek parihar
Programming languages and concepts by vivek pariharVivek Parihar
 
Software programming and development
Software programming and developmentSoftware programming and development
Software programming and developmentAli Raza
 
Programing language
Programing languagePrograming language
Programing languageJames Taylor
 
An overview of computers and programming languages
An overview of computers and programming languages An overview of computers and programming languages
An overview of computers and programming languages Ahmad Idrees
 
ICT, Importance of programming and programming languages
ICT, Importance of programming and programming languagesICT, Importance of programming and programming languages
ICT, Importance of programming and programming languagesEbin Robinson
 
Principles of programming languages. Detail notes
Principles of programming languages. Detail notesPrinciples of programming languages. Detail notes
Principles of programming languages. Detail notesVIKAS SINGH BHADOURIA
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programmingSangheethaa Sukumaran
 
introduction to programming languages
introduction to programming languagesintroduction to programming languages
introduction to programming languagesNaqashAhmad14
 
Principles of-programming-languages-lecture-notes-
Principles of-programming-languages-lecture-notes-Principles of-programming-languages-lecture-notes-
Principles of-programming-languages-lecture-notes-Krishna Sai
 
Computer programming programming_langugages
Computer programming programming_langugagesComputer programming programming_langugages
Computer programming programming_langugageseShikshak
 
Programming language design and implemenation
Programming language design and implemenationProgramming language design and implemenation
Programming language design and implemenationAshwini Awatare
 

What's hot (20)

Ch1 language design issue
Ch1 language design issueCh1 language design issue
Ch1 language design issue
 
Logical programming languages and functional programming languages
Logical programming languages and functional programming languagesLogical programming languages and functional programming languages
Logical programming languages and functional programming languages
 
The Programmer Life Cycle
The Programmer Life CycleThe Programmer Life Cycle
The Programmer Life Cycle
 
Ppt 1
Ppt 1Ppt 1
Ppt 1
 
Evolution and History of Programming Languages - Software/Hardware/System
Evolution and History of Programming Languages - Software/Hardware/SystemEvolution and History of Programming Languages - Software/Hardware/System
Evolution and History of Programming Languages - Software/Hardware/System
 
Programming languages and concepts by vivek parihar
Programming languages and concepts by vivek pariharProgramming languages and concepts by vivek parihar
Programming languages and concepts by vivek parihar
 
Notacd07
Notacd07Notacd07
Notacd07
 
Software programming and development
Software programming and developmentSoftware programming and development
Software programming and development
 
Programing language
Programing languagePrograming language
Programing language
 
An overview of computers and programming languages
An overview of computers and programming languages An overview of computers and programming languages
An overview of computers and programming languages
 
Introduction to programming
Introduction to programmingIntroduction to programming
Introduction to programming
 
PROGRAMMING AND LANGUAGES
PROGRAMMING AND LANGUAGES  PROGRAMMING AND LANGUAGES
PROGRAMMING AND LANGUAGES
 
ICT, Importance of programming and programming languages
ICT, Importance of programming and programming languagesICT, Importance of programming and programming languages
ICT, Importance of programming and programming languages
 
Principles of programming languages. Detail notes
Principles of programming languages. Detail notesPrinciples of programming languages. Detail notes
Principles of programming languages. Detail notes
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programming
 
introduction to programming languages
introduction to programming languagesintroduction to programming languages
introduction to programming languages
 
Programming languages
Programming languagesProgramming languages
Programming languages
 
Principles of-programming-languages-lecture-notes-
Principles of-programming-languages-lecture-notes-Principles of-programming-languages-lecture-notes-
Principles of-programming-languages-lecture-notes-
 
Computer programming programming_langugages
Computer programming programming_langugagesComputer programming programming_langugages
Computer programming programming_langugages
 
Programming language design and implemenation
Programming language design and implemenationProgramming language design and implemenation
Programming language design and implemenation
 

Similar to Cmp2412 programming principles

Python Intro Slides for Students CSC-148 Chapter 1
Python Intro Slides for Students CSC-148  Chapter 1Python Intro Slides for Students CSC-148  Chapter 1
Python Intro Slides for Students CSC-148 Chapter 1Raza Ul Mustafa
 
Python programming
Python programmingPython programming
Python programmingnoor_faiza
 
Programming Paradigm & Languages
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & LanguagesGaditek
 
Programming Paradigm & Languages
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & LanguagesGaditek
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to pythonRanjith kumar
 
notes on Programming fundamentals
notes on Programming fundamentals notes on Programming fundamentals
notes on Programming fundamentals ArghodeepPaul
 
Contents Pre-requisites Approximate .docx
   Contents Pre-requisites  Approximate .docx   Contents Pre-requisites  Approximate .docx
Contents Pre-requisites Approximate .docxShiraPrater50
 
Specification Of The Programming Language Of Java
Specification Of The Programming Language Of JavaSpecification Of The Programming Language Of Java
Specification Of The Programming Language Of JavaKim Moore
 
Introduction to Computer
Introduction to ComputerIntroduction to Computer
Introduction to Computerzaheeriqbal41
 
Computer and Programming
Computer and Programming Computer and Programming
Computer and Programming Mahsa Ch
 
Python-00 | Introduction and installing
Python-00 | Introduction and installingPython-00 | Introduction and installing
Python-00 | Introduction and installingMohd Sajjad
 
Python Programming and ApplicationsUnit-1.docx
Python Programming and ApplicationsUnit-1.docxPython Programming and ApplicationsUnit-1.docx
Python Programming and ApplicationsUnit-1.docxManohar k
 
Introduction to systems programming
Introduction to systems programmingIntroduction to systems programming
Introduction to systems programmingMukesh Tekwani
 

Similar to Cmp2412 programming principles (20)

Python Intro Slides for Students CSC-148 Chapter 1
Python Intro Slides for Students CSC-148  Chapter 1Python Intro Slides for Students CSC-148  Chapter 1
Python Intro Slides for Students CSC-148 Chapter 1
 
Python Lecture 1
Python Lecture 1Python Lecture 1
Python Lecture 1
 
Python programming
Python programmingPython programming
Python programming
 
MODULE 1.pptx
MODULE 1.pptxMODULE 1.pptx
MODULE 1.pptx
 
Programming Paradigm & Languages
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & Languages
 
Programming Paradigm & Languages
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & Languages
 
Ic lecture8
Ic lecture8 Ic lecture8
Ic lecture8
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Lecture 1-3.ppt
Lecture 1-3.pptLecture 1-3.ppt
Lecture 1-3.ppt
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
 
notes on Programming fundamentals
notes on Programming fundamentals notes on Programming fundamentals
notes on Programming fundamentals
 
Contents Pre-requisites Approximate .docx
   Contents Pre-requisites  Approximate .docx   Contents Pre-requisites  Approximate .docx
Contents Pre-requisites Approximate .docx
 
Specification Of The Programming Language Of Java
Specification Of The Programming Language Of JavaSpecification Of The Programming Language Of Java
Specification Of The Programming Language Of Java
 
Introduction to Computer
Introduction to ComputerIntroduction to Computer
Introduction to Computer
 
df
dfdf
df
 
Lecture01 - Fundamental Programming with Python Language
Lecture01 - Fundamental Programming with Python LanguageLecture01 - Fundamental Programming with Python Language
Lecture01 - Fundamental Programming with Python Language
 
Computer and Programming
Computer and Programming Computer and Programming
Computer and Programming
 
Python-00 | Introduction and installing
Python-00 | Introduction and installingPython-00 | Introduction and installing
Python-00 | Introduction and installing
 
Python Programming and ApplicationsUnit-1.docx
Python Programming and ApplicationsUnit-1.docxPython Programming and ApplicationsUnit-1.docx
Python Programming and ApplicationsUnit-1.docx
 
Introduction to systems programming
Introduction to systems programmingIntroduction to systems programming
Introduction to systems programming
 

Recently uploaded

How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Pooja Bhuva
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 

Recently uploaded (20)

How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 

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