Uploaded by Kleven carl Gindap

PROG-1-MODULE-1

advertisement
Course Intended Learning Outcome (CILO)
At the end of this chapter, the student is expected to:

Demonstrate the characteristics of a good IT research and analyze the
difference of IT researches to the researches of other computing discipline.
Introduction
There are so many facts about programming. Some love it. Some hate it. Some
call it mathematics, others philosophy, and making models on it is mostly a part of
physics. It definitely is a skill and it’s also an art. It does not require a lot of knowledge, it
is a way of thinking and it becomes an intuition after a lot of experience.
Learning to program is very different from the learning you do in most other
courses. A lot of time is spent understanding why it will not work and fixing this.
Therefore, some people call the art of programming: “solving puzzles created by your
own stupidity!” While solving these puzzles, you will learn about logic, you will learn to
think about thinking.
Programming is the art and science of designing a program. It is the process of
providing instructions for the microprocessor. It involves activities such as analysis,
developing, understanding, generating algorithms, verification of requirements of
algorithms including their correctness and resources consumption, and implementation
of algorithms in a target programming language.
1|P age
ENGAGE
INSTRUCTIONS:
Watch the film, ‘The Imitation Game”
and create a review by considering
the following:
1. Describe the important things
that happen in the film at the
same time as you present the
most important characters.
2. Don't give away the whole
plot but your opinion and
insight on how is this film
become relevant to you as an
IT student.
3. State the most significant
lesson you learned from this
film.
https://www.youtube.com/watch?v=U_xE807vc6g
EXPLAIN
I. Basics of Computing, Programming and Debugging
Everything comes from the basic. So as computing and programming. Seeing
and experiencing various systems and applications before our very eyes, we still
wonder how did it get there. What is the formula behind these significant changes on
how people do things and execute processes?
A. Computing
 Computing is one of the fundamental foundation of today’s backbone of
the society which is technology.
 During the last several decades it has emerged as a very important part of
science. [1]
 It coordinates both hardware and software to function and solve several
computational and systematical problems.
2|P age
B. Programming


A process that leads from an original formulation of a computing problem
to executable computer programs.
The purpose of programming is to find a sequence of instructions that will
automate performing a specific task or solving a given problem
LINE OF CODE

A single instruction for the computer to perform.
PROGRAM



A program is a set of step-by-step instructions that tells or directs the computer what to
do.
An independent collection of lines of code that serves one or more overall function.
A program is like a house and lines of code are like individual bricks.
INPUT


Data that are fed to a program for it to operate upon.
Example: value of x and y or any variables specified in the program that were provided
by the user.
OUTPUT

What the computer provides in return after running some lines of code.
ALGORITHM

A process or set of rules to be followed in calculations or other problem-solving
operations, especially by a computer. It contains formulas, expressions, etc. that
completes the logical instruction.
3|P age
PROGRAMMER

A programmer is the person who designs a program. The programmer is the one who
writes the sequence of instruction called algorithm.
FLOWCHART

Flowchart is a graphical or symbolic representation of an algorithm or process used in
designing or planning the solution to a problem.
PROGRAMMING LANGUAGE

It is any kind of languages use for expressing a set of detailed instructions for a
computer. It is classified based on level and generations. Ex. Python, C, Java, etc.
SOURCE CODE

It is a computer program in its original programming language (as Python or C) before
translation into object code usually by a compiler. Source code are written by the
programmers.
COMPILER

(Execute Later) – is a program that translates all the source codes of a program written
in a high-level language into object codes prior to the execution of the program
INTERPRETER

(Execute Immediately) – a computer program that converts each procedural
language statement into machine language and executes it immediately, statement
by statement
CODE EDITOR

This is an application software use to write codes or program in the form of computerbased or mobile platforms. It can be considered as Integrated Development
Environment. Example are Spyder, Notepad++, Sublime, etc.
4|P age
OBJECT CODE

It is more commonly referred to as the binary or machine code. Machine code or
machine language is the only language that the computer understands.
Program
Planning
Program
Design
Generation
First Generation:
Machine Language



Second Generation:
Assembly Language


Third Generation:
High-Level or
Procedural
Language


5|P age
Program
Coding
Testing/
Debugging
Description
Machine code is the

computer’s “native
language,”.
The only language that a
computer can “understand.”
It is the basic language of
the computer, representing
data 1s and Os.
Assembly Language uses 
symbolic instruction codes
It
is
a
low
level
programming
language
that allows a programmer
to write a program using
abbreviations or more easily 
remembered words instead
of numbers.
A
high-level,
or 
procedural/objectoriented,
language
resembles some human
language such as English
It tells the computer to do
something
Document
-ation
Example
1010101010101
the letters “MP”
could be used to
represent
the
instruction MULTIPLY
and
STO
(to
represent STORE).
ADD for Addition
and
SUB
for
subtraction
High-level
languages
are
more like human
languages such as
COBOL, FORTRAN,
PASCAL
and
C
Language
Generation
Fourth Generation:
Very-High-Level or
Problem-Oriented
Languages


Fifth Generation:
Natural Languages

Description
Example
It tells the computer what to  Fourth-generation
do. They are much more
languages are
user-oriented and allow users
even closer to
to develop programs with
human language
fewer commands compared
like SQL or
with procedural language
Structured Query
Most of them are used to
Language
access database
Fifth-generation languages  Natural Languages
are used mainly for artificial
are of two types.
intelligence and
neural
The first comprises
networks.
ordinary
human
languages: English,
Spanish and so on.
 The second type
comprises
programming
languages that use
human language
to give people a
more
natural
connection
with
computers.
C. Debugging
 It is the process of correcting programming errors


Debugger is used for testing a program and
locating program errors.
Program errors are most likely causes a program
or system not to function. It could be in different
forms or variations depending on how the
programmer commits them. The following are
the two of the most common programming
errors a program might encounter. Though,
there are lots of other variations of error that we
will be dealing on the succeeding topics.
o Syntax Error – occurs when there is an error in the structure of the codes
o Logical Error – occurs when there is an error to the understanding of the
programmer about the given problem
6|P age
II. Procedural Programming
PROGRAMMING
IMPERATIVE
DECLARATIVE
A programming paradigm is a style or “way” of programming. Some languages
make it easy to write in some paradigms but not others. The two paradigms are
Imperative and Declarative programming:
In Imperative Programming the control flow is an explicit sequence of
commands while in Declarative Programming, programs state the result you want, not
how to get it. In other words, in imperative you can code all the steps in the desired
outcome while in declarative, you can code the desired outcome without the steps.
IMPERATIVE PROGRAMMING
Uses statements that change a
program's state. It consists of
commands for the computer to
perform.
■ It focuses on HOW to achieve our
goal.
■ C, Java
■ HOW to achieve our goal
Example:
– Take the next student from the list
– If the student lives in Tanza, show
their details
– If there are more student in the list,
go to the beginning
■
7|P age
DECLARATIVE PROGRAMMING
■
■
■
A style of building the structure and
elements of computer programs, that
expresses the logic of a computation
without describing its control flow
It focuses on WHAT we want to achieve.
SQL
■ WHAT we want to achieve
Example:
– Show student details of every student
living in Tanza
PROGRAMMING
IMPERATIVE
PROCEDURAL
DECLARATIVE
OBJECT ORIENTED
PROCEDURAL PROGRAMMING
■
■
■
■
Derived
from
structured
programming, based upon the
concept of the procedure call.
Code is given more importance
It focusses on transaction or
procedures
Example: C
OBJECT-ORIENTED PROGRAMMING
■
■
A language model organized around
objects rather than "actions" and data
rather than logic
Data is given more importance
It focuses on object
■
Example: JAVA
■
Procedural - It contains a systematic order of statements, functions and commands to
complete a computational task or program.
Procedures, also known as routines, subroutines, or functions (not to be confused with
mathematical functions, but similar to those used in functional programming), simply
contain a series of computational steps to be carried out.
PYTHON language is under Imperative programming and can be used in procedural
programming but it can also support object-oriented programming. That only shows
how powerful the python language, that it can be used differently depending on the
need and purpose.
8|P age
PROCEDURAL PROGRAMMING
■
It focuses on transaction
PROCEDURAL PROGRAMMING
OBJECT-ORIENTED PROGRAMMING
9|P age
OBJECT-ORIENTED PROGRAMMING
■
It focuses on object
III. History and Background of Python Programming
A. What is Python?
Python is a modern, general-purpose, object-oriented, high-level programming
language.
B. General Characteristics of Python
It is a general purpose interpreted programming language. No need to compile the
code. The Python interpreter reads and executes the python code directly.
It is a language that supports multiple approaches to software design principally
structured and object-oriented programming.
It provides automatic memory management and garbage collection. No need to
explicitly allocate and deallocate memory for variables and data arrays. No memory
leak bugs.
It is dynamically typed - No need to define the type of variables, function arguments
or return types.
It is extensible. It is designed to allow the addition of new capabilities and
functionality.
C. History of Python Language
“Over six years ago, in December 1989, I was looking for a "hobby" programming
project that would keep me occupied during the week around Christmas…I chose
Python as a working title for the project, being in a slightly irreverent mood (and a big
fan of Monty Python's Flying Circus).”
-
Python creator Guido Van Rossum, from the foreword to Programming Python (1st ed.)
Goals:




An easy and intuitive language just as powerful as major competitors
Open source, so anyone can contribute to its development
Code that is as understandable as plain English
Suitability for everyday tasks, allowing for short development times
10 | P a g e






IV.
Guido van Rossum was employed by
Google for years, as this is one of the many
companies that use Python.
He is currently working for another user of
Python: Dropbox.
He still is the moderator of the language, or
as he is called by the Python community:
the “benevolent dictator for life”.
A practical advantage of Python is that it is
free, and so are all add-ons, which have
been developed by the large (academic)
Python community.
Some have become standards of their own,
such as the combination Numpy/Scipy/Matplotlib. These scientific libraries(or
modules), in syntax(grammar) heavily inspired by the software package MATLAB,
are now the standard libraries for scientific computing in Python.
There are currently two versions of python: Python 2 and Python 3. Python 3 will
eventually supercede Python 2, but it is not backward-compatible with Python 2.
A lot of existing python code and packages has been written for Python 2, and it
is still the most wide-spread version.
Compiled Languages vs. Interpreted Languages
11 | P a g e
Comparison between Compiled and Interpreted Language
INTERPRETED LANGUAGE
■
■
■
■
■
COMPILED LANGUAGE
Faster development
o Easier debugging
o Debugging
can
stop
anywhere, swap in new
code, more control over
state of program
(almost always) Takes less code to
get things done
Slower programs
o Sometimes
as
fast
as
compiled, rarely faster
■
Less control over program behavior
■
12 | P a g e
■
■
■
Longer development
o Edit / compile / test cycle is
longer!
Harder to debug
o Usually
requires
a
special
compilation
(almost always) Takes more code to get
things done
Faster
o Compiled code runs directly on
CPU
o Can communicate directly with
hardware
More control over program behavior
V. The Spyder Integrated Development Environment
Spyder is a MATLAB-like IDE for scientific computing with python. It has the many
advantages of a traditional IDE environment, for example that everything from code
editing, execution and debugging is carried out in a single environment, and work on
different calculations can be organized as projects in the IDE environment.
A. Some advantages of Spyder:
• Powerful code editor, with syntax high-lighting, dynamic code introspection and
integration with the python debugger.
• Variable explorer, IPython command prompt.
• Integrated documentation and help.
B. Running Python: Installing it yourself
There are many ways to install Python on your laptop/PC/etc.
 https://www.python.org/downloads/
 https://www.anaconda.com/download/
 https://www.enthought.com/product/enthought-python-distribution/
 https://python-xy.github.io/
BU’s most popular option: Anaconda
■ https://www.anaconda.com/download/
■ Anaconda is a packaged set of programs including the Python language, a
huge number of libraries, and several tools and includes the SPYDER IDE. (the
main interface is shown below)
13 | P a g e
EVALUATE
WORKSHEET 1
MOVIE REVIEW: THE IMITATION GAME
Name: _______________________________
Yr. and Section: ______________________
Score: ____________
Date: _____________
INSTRUCTIONS: Watch the film, ‘The Imitation Game” and create a review by
considering the following.
1. Describe the important things that happen in the film at the same time as you
present the most important characters.
2. Don't give away the whole plot but your opinion and insight on how is this film
become relevant to you as an IT student.
3. State the most significant lesson you learned from this film.
14 | P a g e
WORKSHEET 2
INTERVIEW: THE FIRST STEP OF A N
OVICE PROGRAMMER
Name: _______________________________
Yr. and Section: ______________________
Score: ____________
Date: _____________
INSTRUCTIONS: Programming is indeed one of the most unforgettable subject that an IT
student can experience in College and learning from other’s experiences might help
you to understand better and somehow give you answers why did you really choose
this profession. Hence, look for two higher years IT students and ask the following
questions.
Name of selected student: ___________________________________
Course, Year and Section: ____________________________________
1. What is the best programming language for you? Why?
_____________________________________________________________________________________
_____________________________________________________________________________________
2. What Integrated Development Environment do you use when coding? Why?
_____________________________________________________________________________________
_____________________________________________________________________________________
3. Which topic in programming do you enjoy most and you least enjoy?
_____________________________________________________________________________________
_____________________________________________________________________________________
4. What programming error do you mostly commit? How do you debug it?
_____________________________________________________________________________________
_____________________________________________________________________________________
5. What do you do if you keep encountering similar programming error repeatedly?
_____________________________________________________________________________________
_____________________________________________________________________________________
6. What life lesson did programming teach you?
_____________________________________________________________________________________
_____________________________________________________________________________________
15 | P a g e
Download