You are on page 1of 2

COMPROG 1 MIDTERM REVIEWER

PROBLEM – something the result of which is not readily MODULO OPERATOR / remainder operator (%) - returns the
available. remainder when the first operand is divided by the second
operand.
Law of Equifinality – same goal can be achieved through
different courses of action and a variety of paths. NATURAL LANGUAGE – languages that humans speak
MACHINE LANGUAGE – composed of binary digits that
ALGORITHMS – relates to the name of mathematician Al-
computers can understand.
khowarizmi, which means a procedure or a technique.
PROGRAMMING LANGUAGE - Set of commands, instructions,
 A set of steps that generates a finite sequence of and other syntax use to create a software program.
operations which leads to the solution of a given
problem. PROGRAM – organized list of instructions that causes
computer to behave in a predetermined manner.
CHARACTERISTICS OF ALGORITHMS
PYTHON – conceptualized by Guido van Rossum
Input – algorithm may or may not require input
 Started in 1989
Output – each algorithm is expected to produce at least one
 Named after the British TV show Monty Python
result
 Python 1: 1994, Python 2:2000, Python 3:2008
Definiteness – Each instruction must be clear and
- A high level programming language with applications in
unambiguous.
numerous areas.
Finiteness – If the instructions of an algorithm are executed,
- An interpreted language, which means that each line is
the algorithm should terminate after finite number of steps
executed as it is entered.
FLOWCHART – is a pictorial or diagrammatic representation of
Editor- where you type your code
an algorithm so that it can be easier and quicker to
understand. Code- commands or instructions written in a particular
programming language
 SYSTEM FLOWCHART – they contain solutions of many
problem units together that are closely related to each Interpreter- prompts the computer to execute or run your
other and interact with each other to achieve a goal. program
 PROGRAM FLOWCHART – flowcharting symbols used
mirror computer programs Integrated Development Environment (IDE) – helps create
 They contain steps to solve a problem to achieve a programs and applications in diff programming languages.
specific result. Interpreter – a program that run scripts written in an
 Any error can be easier to detect because it is a interpreted language.
visual representation of the logic of a program
Indention – indicates groups or blocks of code

Program comment (#) – notes or reminders

Printing Text – used to display output or text

.py – extension for python files

>>> - prompt symbol of Python console

Variable – an identifier or name for a reserved memory


location for storing values.

Python is dynamically-typed – the type or the memory


management for the variable will only be determined during
runtime.

DATA TYPE – determines the kind of information that is stored


PSEUDOCODE – combining natural and programming in a variable
language to describe computer algorithms.
1. Numeric
- structural conventions of a programming language, but is  Integer (int) – for whole numbers
intended for human reading.  Float (float) – for decimals
2. String (str) – for characters; letters, numbers, symbol
- simple way to represent an algorithm or program. 3. Boolean (bool) – George Boole – for true or false

BASIC OPERATORS

 Arithmetic Operators – mathematical operations


 Comparison (Relational) Operators – tru or folz
 Assignment Operators – assigns value to a variable
 Logical Operators – combining logical statements
ESCAPE CHARACTERS (\)– allows us to avoid errors caused by For Loop - used for sequential traversal.
using “illegal characters”
 The range() Function - To loop through a set of code
\n – inserts a new line in the text a specified number of times, we can use the range()
function.
\t – inserts a tab in the text
 Else in For Loop - specifies a block of code to be
\’ – inserts a single quote character executed when the loop is finished. The else block
will NOT be executed if the loop is stopped by a
\” - inserts a double quote character break statement.
\\ - inserts a backslash character

CONCATENATION ( + or , ) – process of merging two or more


strings, on either sides

TYPE CASTING - the method to convert the variable datatype


into a certain data type.

 Explicit type conversion – done by the user


 Implicit type conversion – automatically performed
by the interpreter

PRECISION HANDLING USING % - determines the number of


digits to be displayed after the decimal point

FIRST BUG – Harvard University, 1947

 Mark II was having consistent errors; a literal bug


disrupted the electronics of the computer.

TYPES OF ERRORS:

 Syntax Error (parsing error) – caused by improper


format or syntax. Pointed out during translation.
 Occurs during interpretation time.
 Semantic Error – when the syntax is correct but the
program logic is not, resulting to incorrect output.
 Occurs during runtime.

DEBUGGING – process of finding and correcting errors or


bugs in the program code.

How to avoid debugging?


-Understand the problem
-Start small
-Keep improving your code

DEBUGGER – helpful for finding and correcting bugs that are


difficult to find.

Decision Control statement - a statement that determines the


control flow of a set of instructions.

Nested if - an if-elif-else construct inside another if-elif-else


construct.

Nesting - functions that you define inside other functions. Any


number of these statements can be nested inside one
another.

While Loop - used to execute a block of statements


repeatedly until a given condition is satisfied.

 The break Statement - With the break statement we


can stop the loop even if the while condition is true
 The else statement - With the else statement we can
run a block of code once when the condition no longer
is true
 The continue Statement - With the continue statement
we can stop the current iteration, and continue with
the next

You might also like