0% found this document useful (0 votes)
2 views

COMPUTER-PROGRAMMING-MIDTERMS-REVIEWER

The document serves as a comprehensive reviewer for computer programming, covering essential concepts such as programming languages, variables, data types, and control structures. It explains the differences between interpreters and compilers, outlines basic input/output operations, and introduces loops and functions in programming. Key programming principles and examples in languages like Python, C++, and Java are also included to illustrate the concepts discussed.

Uploaded by

yuji
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

COMPUTER-PROGRAMMING-MIDTERMS-REVIEWER

The document serves as a comprehensive reviewer for computer programming, covering essential concepts such as programming languages, variables, data types, and control structures. It explains the differences between interpreters and compilers, outlines basic input/output operations, and introduces loops and functions in programming. Key programming principles and examples in languages like Python, C++, and Java are also included to illustrate the concepts discussed.

Uploaded by

yuji
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

COMPUTER PROGRAMMING REVIEWER

Module 1: Introduction to Computer rather than the underlying hardware


Programming architecture.

Programming or Computer Programming Translator


- is a way of giving an instruction to a - to translate the source code into
computer to perform a specific task. computer codes which is basically a
- also referred to as coding set of binary numbers.

Computer Program Interpreters


- A sequence of instruction that a computer - Some programming language
is executing doesn't need to complete the
program before you execute it.
Software - Employs one of the following
- A set of computer programs programming execution strategies

Computer System 1. Parse source code and explicitly


- made of electronic devices which operates execute.
from 0v to 5v. 2. Translate the source code to
some effective intermediate
Computer Design Voltage representation and execute it
1. High - corresponds to ranges close immediately;
to 5v 3. Execute the stored pre-compiled
2. Low - corresponds to the voltages code created by a compiler that is
near 0v or ground. part of the interpreter program.

Binary Some of the most common


- computer number system programming language who still
- series of binary digits (Bits) of 1 and 0 use interpreter are the following:
1. Perl
Programming Languages 2. Python
1. Low-Level Languages - It has no 3. Matlab
abstraction and the programming 4. Ruby
rely closely to the computer
architecture. Compilers
a. Opcode - The compiler is a computer
b. Operand program that converts machine code
2. High- Level Languages - It has a written in one programming
high-level of abstraction and focus language (source language) into
mainly on the programming logic another language (target language).
The most common language we container for any values you want to assign
used usually uses compilers are: or inputs from the users.
1. C
2. C++ The name of the variable must have:
3. Java 1. The name of the variable must not
4. Visual Basic be any reserved words/syntax of the
programming language you are
Assembler using.
- Assembly language (or assembler
language), also abbreviated asm, is 2. The name can be upper case or
any low-level programming language lower case and digits.
in which the instructions in the
language and the computer code 3. The digits must be combined to a
instructions of the machine letter for it to be usable.
correlates quite strongly.
4. The variable name must start with a
Module 2: Print Function letter

Print() 5. The only acceptable character is


- used here is a name for a function underscore ( _ ) and these character
- used to print or display a specific values is considered as letter
you specify.
6. The variable name is case sensitive
Function thus, same name with different case
- An cause an effect or evaluate a value. is a different variables.

Argument Variable Assignments


- A function always have a component - may differ based on the
which is called as argument. programming language you are
- just like an argument in a mathematical using.
functions. - If you assign any value to a
nonexistent variable, the variable will
String be automatically created. You don't
- a text coincide in a quotes is identified as need to do anything else.
string
- All text inside a quotation will not be Module 4: Data Types
considered as part of a code thus will not be
executed as instruction. Integers
- These are numbers which are
Module 3: Variables devoid of the fractional part.
Variables - composed of signed and unsigned
- placeholder for values non-fractional numbers.
- serve a
C++ and Java - comes from Boolean Algebra which is
int a = 1; introduced by George Bool (1815-1864) in
int myVar; his book entitled "The Laws of Thought.

Python C++ and java


a=5 boolean isHappy = true;
b = "Juan" boolean isSad = false;

Floats Python
- The float type are the numbers that have a print(10 > 9)
non-empty decimal fraction. print(10 == 9)
- can be signed or unsigned print(10 < 9)
number which has a fractional part after the
decimal point. Module 5: Operators

C++ and Java Assignment Operators


float c; - are used to put values in a variable.
float d = 3.44; - must be confused with equal-to
operators which is mainly used for
Python comparison.
myVar = 2.5
C = -0.4 Arithmetic Operators
- comprises operators for carrying out
Floating-point numbers arithmetic tasks such as addition, and
- assign a number in a variable with decimal subtraction.
place whether it is between two numbers or
between a zero and a number, For example the modulus operator (%)
returns the remainder value in division
Strings operations.
- basically for processing text and not a
number.
- Strings usually comes with quotes upon Relational Operators
encoding. - used for comparing values
- they include greater than, less than,
"I love programming." equal-to, not-equal-to.

Boolean Values Logical Operators


- use to represent very abstract values such - used to compute logical operations
as truthfulness. - commonly used logical operators are and ,
- used when you want to create a variable or , not.
that will store a truthfulness of a statement.
Integer Division ( // ) Control Structures
- A // (double slash) sign is an integer - allow the flow of control to change such
divisional operator. It differs from the that statements can be executed based on
standard / operator in two some condition,
Details:
Boolean Expression
● its result lacks the fractional part - it's - evaluates to either True or False and can
absent (for integers), or is always be used as the condition in a control
equal to zero (for floats); structure.

● this means that the results are Relational Operators (Comparison
always rounded; Operators)
- used in boolean expression
Modulo (%) - such as '==' (equality), '!=' (not equal), '<'
- The result of the operator is a remainder (less than), '>=' (greater or equal),
left after the integer division.
Selection
Module 6: Basic Input/Output Operation - These types of control structures allow
different blocks of code to be executed
Input/Output based on the Boolean expression. There
- the transmission between a data are three basic types in Python that can be
information system, like a computer, and a used.
user which can be a human or some other
data information system. 1. if
2. if-else
Inputs - the signals or data to be 3. if-elif-else
received by the system
The if statement allows to only execute one
num = input('Enter a number: ') or more statements when some condition is
met.
Outputs - outputs are the signals or data
sent from it. The addition of the else statement allows
an alternative action
print (I study in Batangas State University)
and the addition of elif, which stands for
Output formatting 'else if', allows for different conditions and
- Sometimes we would like to format our having different actions for each of them.
output to make it look attractive. This can be
done by using the str.format() method. This Boolean Operators
method is visible to any string object - In addition to relational operators, we can
also use Boolean operators (also called
Boolean logical operators) to
- A data type that can have either a True or
False value.
form more complex Boolean expressions. For Loop
There are three basic types: 'and', 'or', and A for loop in Python is a control flow
'not'. statement that is used to repeatedly execute
a group of statements as long as the
Module 7: Loops condition is satisfied. Such a type of
statement is also known as an iterative
Loops statement. Thus, a for loop is an iterative
- Looping means repeating something over statement.
and over until a particular condition is
satisfied. List
- data structure in Python that is a mutable,
There are two basic types in Python that or changeable, ordered sequence of
can be used: elements.
1. While - Each element or value that is inside of a
2. For list is called an item.
- Just as strings are defined as characters
While Loop between quotes, lists are defined by having
If it evaluates to False, the while loop is values between square brackets [ ] .
finished. In other words, the program flow
will continue with the first statement after
append() Adds an element at
the while statement, i.e. on the same the end of the list
indentation level as the while loop.
clear() Removes all the
If the condition is evaluated to True, the elements from the
body, - the indented block below the line list
with "while" - gets executed. After the body copy() Returns a copy of
is finished, the condition will be evaluated the list
again. The body of the loop will be executed
as long as the condition yields True. count() Returns the number
of elements with
the specified value
The Else Part
extend() Add the elements
This is an unfamiliar construct for many of a list (or any
programmers of traditional programming iterable), to the end
languages. The statements in the else part of the current list
are executed, when the condition is not
index() Returns the index
fulfilled anymore. of the first element
with the specified
We need to understand a new language value
construction, i.e. the break statement, to
obtain a benefit from the additional else insert() Adds an element at
the specified
branch of the while loop.
position

pop() Removes the


element at the
specified position

remove() Removes the item


with the specified
value

reverse() Reverses the order


of the list

sort() Sorts the list

Functions
- Function is a group of statement that
perform a specific task.
- It help break the program into smaller and
modular chunks.
- Functions make it more organized and
manageable to avoid repetition and makes
the code reusable.

1.Functions introduce two new keywords:


def and return
2.Functions accept arguments
3.Functions contain code and (usually)
documentation

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy