Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
79 views

Module 3 Computer Programming

Computer Programming for Engineering Module 3

Uploaded by

Ryza Jane
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views

Module 3 Computer Programming

Computer Programming for Engineering Module 3

Uploaded by

Ryza Jane
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 62

OOP Unit 1: Introduction / Orientation

Introduction /

Orientation MODULE 1

PREPARED BY:

ENGR. MARIA LORENA SP. VILLENA


DR. MA. MAGDALENA V. GATDULA
ENGR. LECH WALESA NAVARRA
1
OOP Unit 1: Introduction / Orientation

UNIT

Introduction / Orientation
1
LESSONS COVERED

LESSON 1 - DISCUSSION OF VISION, MISSION, GOALS, CORE VALUES AND 25


ASPIRATION.

DURATION: 6 hours per week

INTRODUCTION

It is important for every student to identify and inculcate the importance of the
mission, vision, and core values of the University before learning the subject matter.
Students must able to understand that the University is knowledge – generating
institution and globally recognized for excellent instruction and exists to produce highly
competent, ethical and service oriented professionals – the students of the future.
Objectives/Competencies
The objective of this lesson is to remember, understand, and provide
expectations and insights about the mission, vision, and core values of the University
and how the subject “feedback and control” can take part in these.
Pretest
The students can state their expectations and participation on the mission,
vision, and core values as well as in the subject of feedback and control.
Lesson Proper
ACTIVITY
---------------------------------------------------------------------------------------------------------------
- -----
1. Try to master and memorize the mission, vision, goals and objectives of the
University.

University Vision
Bulacan State University is a progressive knowledge-generating institution,
globally recognized for excellent instruction, pioneering research, and responsive
community engagements.
2
OOP Unit 1: Introduction / Orientation

University Mission
Bulacan State University exists to produce highly competent, ethical and
service-oriented professionals that contribute to the sustainable socio-economic
growth and development of the nation

Core Values: SOAR BulSU!


Service to God and Community
Order and Peace
Assurance of Quality and Accountability
Respect and Responsibility

The BulSU Ideal Graduates Attributes (BIG A) reflect the graduate’s capacity
as: a. highly and globally competent;
b. ethical and service-oriented citizen;
c. analytical and critical thinker; and
d. reflective life-long learner.

25 ASPIRATIONS FOR BULACAN STATE UNIVERSITY


In the next 25 years, Bulacan State University aspires to be:
1. Crown-jewel of Cultural Heritage Preservation
2. Bastion of Student Leadership and Nation-Building
3. Mirror of International Education Standards
4. Life-Nurturing Soil of the Arts
5. Aegis of Human Resource Empowerment and Professional
Development 6. Vanguard of Filipino Language Enrichment
7. Quintessence of Peace
8. Sanctuary of Orderly and Peaceful Development
9. Herald of Ethical Standards in Educational Administration and Management
10. Forerunner for Highly Scientific and Modernized Athletic Training Program
in the Region
11. Cradle of Licensure Examination Top Passers
12. Seedbed of Relevant Programs on Poverty Reduction and Sustainable
Livelihood
13. Haven of Fulfilled Individuals
14. Trailblazer in Capacity Building for the Workforce
15. Respected Advocate of Indigenous People and Minority Rights 16.
Recognized Leader of Cross-Cultural/Multi-Cultural Borderless University
17. Pillar of Respect to Humanity
18. Model of Sustained Programs
19. Prime Mover of Innovative Technologies in the Region
20. Instiller of the Spirit of Volunteerism
21. Proponent of Inclusive Policies for the Marginalized Sector of the
Society 22. Dwelling-keep of Excellence in Academic Programs
23. Abode of Sustained Participative and Good Governance
3
OOP Unit 1: Introduction / Orientation

24. Global Shelter of Academic Bilateral Exchange


25. Breeding Ground of Tomorrow’s Experts and Lead Agency for Human
Capital Form.
(Source: https://www.studocu.com/ph/document/bulacan-state-university/accountancy/other/25-aspirations-for
bulsu/5363493/view?fbclid=IwAR2kgrZ0HWHBVELnhjp-bwXU2pcxSfFVbtrd5SXhscGC0eMhVSj0_wyi8_s)

ANALYSIS

BULACAN STATE UNIVERSITY (BulSU) is the premiere state-operated


institution of higher learning in the Central Luzon region. It originated as a secondary
school run by the Americans in 1904 and has now progressed into one of the biggest
educational institutions in Region III. BulSU was converted from a college into a
university in 1993 by virtue of Republic Act 7665. Since then, BulSU has grown by
leaps and bounds, in terms of program offerings, faculty qualification, and student
enrolment. It is the vision of the University to be a knowledge-generating institution
globally recognized for excellent instruction, pioneering research, and responsive
community engagement. The University has also maintained the existence of four
external campuses within the province namely Meneses Campus, Hagonoy Campus,
Sarmiento Campus, and Bustos Campus

The University has been consistently producing highly professional, ethical, and
service-oriented individuals who perform well in board examinations with impressive
results consistently exceeding the National Passing Rate and become potent driving
force in the industries in the region and beyond. BulSU has recently received its ISO
9001:2015 Certification, passed the Level II Institutional Accreditation while 50
academic programs of the different Colleges are already accredited by the Accrediting
Agency of Chartered Colleges and Universities (AACCUP), Inc. This was made
possible through the persistent hard work and resolute service of its 1,138 faculty
members and 476 non-teaching personnel who relentlessly cater and furnish the
needs of our 35,958 students.

A Brief History of Bulacan State University

Established

The Bulacan State University started as an intermediate school in 1904. It was


established during the early years of the American occupation by virtue of Act 74 of
the Philippine Commission in 1901, which created the then Department of Public
Instruction with the mandate to establish schools in every pueblo of the country and
reorganize those already existing. Instructions in the intermediate schools established
during that time were supplemented with trade or industrial instruction.

4
OOP Unit 1: Introduction / Orientation

The Bulacan Trade School

In 1907, Governor Teodoro Sandiko of Bulacan started to look for funds to put
up a trade school for his constituents. His efforts paid off when the intermediate school
became the Bulacan Trade School in 1909. The school had an American principal and
five teachers, four of whom are Americans, the so-called Thomasites.

The First Filipino Principal

Upon the implementation in 1918 of the Philippine Autonomy Act passed by the
U.S. Congress in 1916, the Bulacan Trade School was formally turned over to the
Filipinos with Mr. Basilio Abiado as the first Filipino principal. He was later succeeded
by Mr. Dionisio Patag. In 1920, with Mr. Juan Lopez as the principal-teacher, the
intermediate course was finally dissolved to give way for the secondary trade
curriculum. By 1926, the school offered the complete secondary trade curriculum with
Mr. Gonzalo Villaverde as the principal-teacher. Due to limited facilities at the time, the
Bulacan Trade School was sharing the use of the classrooms of Bulacan High School
(now the Marcelo H. del Pilar High School) for their related-subject classes. Mr. Isaias
P. Maclang became the principal of the school in 1931 followed by Mr. Melanio Orbeta,
who took over the position in 1938. Mr. Orbeta held the position throughout the Second
World War and until the reopening of the school in 1945 when Mr. Deogracias P. Flores
succeeded him as the principal.

After the war

In 1945, after repairing the damage suffered during the Second World War; the
school reopened with a few hand tools and materials donated by the U.S. army
stationed in the provincial capital. With the steady increase in enrollment, more
buildings were constructed. In 1949, the United States Information Service (USIS)
donated two Quonset huts, which were used as shops and classrooms. In 1951, the
two-story related subjects building was constructed with funds from the War Damage
Rehabilitation Fund, and in 1952, the one-story Girls' Trades building was built with
half of the cost of construction was donated by the school's PTA.

The Bulacan National Trade School

On June 20, 1953, the school was nationalized under R.A. NO. 908 and
became the Bulacan National Trade School. Through the assistance of the Philippine
Council for US Aid (PHILCUSA) and International Cooperation Agency (ICA) and the
National Economic Council (NEC), the school acquired much-needed office
equipment, tools, machineries and buildings.

The Bulacan School of Arts and Trades

The Bulacan National Trade School was converted into the Bulacan National
School of Arts and Trades (BNSAT) on July 1, 1957 by virtue of R.A. 1800, passed

5
OOP Unit 1: Introduction / Orientation
through the efforts of the then Congressman Florante C. Roque of the First District of
Bulacan. With its conversion, Mr. Santiago G. Roxas was appointed as its first
superintendent. During his term, the school offered the two-year post-secondary
courses with specializations in automotive, machine shop and girls' trade courses. Mr.
Roxas was the first to envision the conversion of the school into a college and
eventually into a university. Later, the name of the school was changed to Bulacan
School of Arts and Trades through legislative action. Mr. Arnulfo M. Tongio of Bacolor,
Pampanga served as Principal until 1963. He was succeeded by Mr. Leandro Jimenez
who served as the school principal until his retirement in 1973. Mr. Roxas retired in
December 1964. He was succeeded by Mr. Deogracias Flores as the second
superintendent of the school.

The Bulacan College of Arts and Trades

By virtue of Republic Act 4470, the Bulacan School of Arts and Trades (BSAT)
was converted into the Bulacan College of Arts and Trades (BCAT) on June 19, 1965.
The Board of Trustees designated Mr. Deogracias Flores as the Acting President of
the College. Upon its conversion, the college began to expand its technical and
technician course offerings by adding shop specialization and also offered the four
year Bachelor of Science in Industrial Education (BSIE) in 1967 with majors in drafting,
machine shop practice, woodworking and automotive, cosmetology, electronics and
electricity.

On September 27, 1967, Mr. Gavino M. Carpio was appointed Acting President
of the College and then full-pledged President the following year. It was during his time
that the five-year engineering programs were added to the courses offered by the
College. Upon his retirement on December 30, 1973, Dr. Antonio T. Federizo, the Vice
President for Academic Affairs, was designated Officer-in-Charge of the College and
later Acting President. He was appointed as full-fledged President on November 29,
1976. In summer of 1977, the College started offering graduate program, the Master
of Arts in Teaching with majors in technical and vocational subjects. After Dr.
Federizo's demise on November 7, 1977, Mr. Rosario Pimentel, the then Vice
President for Academic Affairs was designated as Officer-in-Charge.

On March 27, 1978, Mr. Ernesto Valencia was appointed Acting President of
the College until his retirement on November 7, 1983. Upon his retirement, Dr. Amelia
R. Horca, the College Dean, was designated as Officer- in-Charge of the College.

Dr. Rosario Pimentel

Upon his return after earning his doctorate degree from U.P., Dr. Rosario
Pimentel was appointed as BCAT President on November 26, 1983. Under his able
leadership, the college continued to expand its curricular offerings and develop its
facilities to meet the needs of the growing student population. The teacher education
curriculum added more major fields of specialization in secondary education. New
majors in the engineering program were also added. Doctoral program was offered

6
OOP Unit 1: Introduction / Orientation

and new majors in the master's program were introduced. His term also saw the
completion of the new three-story integrated building (now Federizo Hall), the
constructions of a new canteen, the student services building, the main gate of the
College along McArthur Highway, and the heroes park, and the renovations of shop
rooms. He relentlessly enlisted the support of the parents and the national and local
political leaders for the conversion of the College into a university.

The Bulacan State University

On December 30, 1993, Dr. Pimentel's efforts bore fruit, when President Fidel
V. Ramos signed House Bill 461 into law, known as Republic Act 7665, which
converted the Bulacan College of Arts and Trades into the Bulacan State University,
with him as the first BSU President.

The conversion into a university provided more impetus to the administration to


implement a wide range of institutional development programs, which included
upgrading of academic qualifications of faculty members, streamlining the curricular
programs by creating colleges and institutes, securing state-of-the-art instructional
facilities, physical plant development and expansion, and broadening access to
education by establishing additional satellite campuses.

The University Campuses

The University is now maintaining five campuses within the Province of


Bulacan. In addition to the main campus in the City of Malolos, it has satellite
campuses in the town of Bustos, in the City of San Jose Del Monte, in Matungao,
Bulacan, and in Hagonoy established in 1976,.1998, 2000, and 2011 respectively.

The AACCUP Level 3 Accreditation

The Pimentel administration made bold and decisive moves to achieve higher
levels of excellence in educational services of the institution. In 1997, beginning with
the teacher education and engineering programs, the University submitted itself for
voluntarily accreditation by the Accrediting Agency of Chartered Colleges and
Universities in the Philippines (AACCUP). In July of 2007, the AACCUP granted Level
3 accreditation status to the elementary, secondary and industrial education programs
of the College of Education. These were the first education programs that have been
granted such accreditation status the highest so far among the public higher education
institutions in Region 3. To date, most of the Programs of the University have at least
Level Il accredited status and gearing for Level 3 as well.

The BulSU College of Law

In 2002, a landmark agreement between the University and the Integrated Bar
of the Philippines, Bulacan Chapter, was made to establish the BSI-J - Marcelo H. Del
Pilar College of Law. Subsequently, the Marcelo H. Del Pilar Law Foundation, Inc. was

7
OOP Unit 1: Introduction / Orientation

created to support the program of the college. The Technical Panel for Legal
Education of the Commission on Higher Education hailed this move as innovative -
the first of its kind in the Philippines. The first batch of graduates of the college who
took the 2006 Bar Examinations garnered an impressive passing average of 42.8
percent, which was much higher than the national passing average of 30.6 percent.
With this performance, the statistical data issued by Supreme Court placed the BSU -
Marcelo H. Del Pilar College of Law in number 16 in the ranking of the 103 colleges
of law in the country that participated in the said examinations. Since June 2009,
when the Marcelo H. Del Pilar Law Foundation, Inc. left to the University the sole
responsibility to run its law program, the college was renamed BSU College of Law.

Global Participation

The new millennium saw Bulacan State University going global and
participating in cross-border education with other Asian countries such as South
Korea, Peoples Republic of China, Taiwan, Hong Kong, Singapore, and Malaysia. The
University signed agreements with educational institutions in these countries for the
offering of various programs of the BSU especially the doctoral and master's programs.
The University, in partnerships with Korean institutions, also hosts Korean students
for their English language course. These programs paved the way for the on
going students and faculty exchanges and visitations with those institutions abroad.

The BSU, which started as an intermediate school in 1904, is now a well-known


and respected public university for its achievements. It has produced more than fifty
board examinations topnotch in the fields of engineering, architecture and teacher
education. To date, the University has more than twenty thousand students and
enrolment is increasing. It has one of the largest enrolments among state colleges and
universities outside of Metro Manila. This is an indication that the BSU has earned the
trust and confidence of its clientele as it continues its unwavering commitment to
pursue excellence in providing quality university education to its students.

(Source: https://www.bulsu.edu.ph/about/history)

Students Rule and Regulations

You may see the link below to understand and realize that there is a Student
Law that every student should obey. Please see the link below to know about the
student guidelines and protocols of a good student.

(https://www.bulsu.edu.ph/downloads/files/student_handbook.pdf

) Course Syllabus

This is the course outline of the subject that you will take up in the whole semester. The
syllabus content is based upon the subject and time of the class and the length of the
discussion. It also contains activities, laboratory exercises, assignments and grading
systems. The syllabus will be given upon the start of the class. And every subject has its
own syllabus.

8
OOP Unit 1: Introduction / Orientation Activity 1.1

➢ Go to https://www.bulsu.edu.ph/
➢ Look for the vision, mission and core values of BulSU.
➢ Read about the history of BulSU
➢ Write a 5-paragraph statement about the importance of the Mission, Vision
and Core Values to the development of a University. Also, include how
BulSU manage to SOAR to its current state.
➢ What do you think is the focus of the 25 aspirations for the BulSU?

ABSTRACTION

Activity 1.2

➢ Make a comparison of the Vision and Mission between BulSU and other
Universities and write their similarities and differences.
University Vision Mission Similarity Differences

BulSU

University 1:
_____________________

University 2:
_____________________

APPLICATION
Activity 1.3 – Answer the following questions.
1. What is the importance of a Vision and Mission to a University?
2. Without looking at the notes, write down the Vision, Mission and
Core Values of BulSU.
3. Still, without looking at the notes, write at least 5 out of the 25
aspirations for BulSU
Reflection/Learning Insights
Please fill in the following details for the assessment of what you have
learned.
Name (LN,FN,MI) Means of Contact Info. Date and Time
Communicatio
n (Chat, Text,
Call)
9
OOP Unit 1: Introduction / Orientation

Post-test
Name (LN,FN,MI) Year/Section Activity No. Grade / Score

1.1

1.2

1.3

Average Score

Final Requirement
Name (LN,FN,MI) Year/Section Chapter Grade

Other Parts
SUGGESTED READINGS AND WEBSITES
https://www.bulsu.edu.ph/about/history
https://www.bulsu.edu.ph/about/
https://www.bulsu.edu.ph/
10
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

Review, Programming Concepts,


Basic of Python and
Programming

MODULE 2

PREPARED BY:

ENGR. MARIA LORENA SP. VILLENA


DR. MA. MAGDALENA V. GATDULA
ENGR. LECH WALESA NAVARRA
11
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

UNIT

2Review, Programming Concepts,


Basic of Python and
Programming

LESSONS COVERED

Lesson 1 - ALGORITHM, PSEUDO CODE AND FLOWCHART


Lesson 2 - PROGRAMMING LANGUAGES CONCEPTS
Lesson 3 - BASICS OF PYTHON
Lesson 4 - PROGRAMMING PYTHON

DURATION: 6 hours per week

INTRODUCTION

This module covers the following lessons; First, review of the previous
programming language algorithm, pseudocode, and the use of flowchart. Second is
understanding the ABC’s of programming language concepts. Third, the brief history
of python and its basic functions. The last one is the start of programming using python
language.
12
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

LESSON 1: REVIEW OF ALGORITHM, PSEUDO CODE AND


FLOWCHART. DURATION: 3 hours

INTRODUCTION
A program is a set of instructions that tell the computer to do things differently;
sometimes the instruction it needs to perform depends on what happens when the
previous instruction was given. Flowcharts are written from the top of a page to the
bottom, with program flow. That command is put in the correct shape box and arrows
are used to guide flow of the program. Pseudocode is a tool by which computer
algorithms are represented using a combination of natural language and
programming.
OBJECTIVES
When you finish this Lesson, you will be able to:
• Recall the concept of different steps in solving problem
• Write algorithm using pseudo code and flowchart to solve problems; and •
Acquire simple problem-solving skills.

PRE-TEST
How about we assess your insight into the exercise by responding to the
accompanying questions:
1. What are the different steps in solving problems?

LESSON PROPER/COURSE METHODOLOGY


Activity 2.1.1
This is a review of the previous subject that you took up last semester. Here
are some prompt exercises to analyze your insight in the lesson we will discuss later.
1. Write algorithm to find the greater number between two numbers?

2. Write pseudo code that reads two numbers and multiplies them together and print out
their product.
13
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

3. Draw the flowchart based on the given the algorithm.


▪ Initialize sum = 0
▪ Enter two numbers
▪ Add them and store the result in sum
▪ Print sum

Analysis
In order to better understand our lesson, you need to analyze and reflect on
your previous activities.
1. The above activities made me discover
______________________________________________________________
______________________________________________________________
______________________________________________________________ 2.
It helped me understand and assess that
______________________________________________________________
______________________________________________________________
______________________________________________________________ 3.
Now, I want to try and examine more on
______________________________________________________________
______________________________________________________________
______________________________________________________________

14
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

Abstraction
A typical programming task can be divided into two phases:
➢ Problem solving phase
a. produce an ordered sequence of steps that describe solution of
problem
b. this sequence of steps is called an algorithm
➢ Implementation phase
a. implement the program in some programming language
Steps in Problem Solving
➢ First produce a general algorithm (one can use pseudocode) ➢ Refine
the algorithm successively to get step by step detailed algorithm that is
very close to a computer language.
➢ Pseudocode is an artificial and informal language that helps
programmers develop algorithms.
➢ Pseudocode is very similar to everyday English.

Algorithm

Algorithm is a step-by-step procedure for solving a problem. The word is


derived from the phonetic pronunciation of the last name of Abu Ja'far Mohammed ibn
Musa al-Khowarizmi. Algorithm is not the complete code or program, it is just the core
logic of a problem, which can be expressed either as an informal high-level description.

How to Write an Algorithm?


Algorithms are never written to support a programming code. There are no well
defined standards for writing algorithms; it is problem and resource dependent. Most
programming languages share basic code constructs like loops (do, for, while), flow
control (if-else), etc. These common constructs can be used to write an algorithm.
Algorithm writing is a process and is executed after the problem is well-defined and
written in a step-by-step manner.
a. Define the problem: state the problem in clear and concise terms. b. List the
inputs (information needed to solve the problem) and the outputs (what the
algorithm will produce as a result)
c. Describe the steps needed to convert or manipulate the inputs to produce
the outputs. Start at a high level first and keep refining the steps until they are
effectively computable operations.
d. Test the algorithm: choose data sets and verify that your algorithm works!

Classification of Algorithm According to Structures


a. Sequence - The sequence structure is the construct where one statement is
executed after another.
b. Branching (Selection) - The branching/selection structure is the construct
where statements can execute or skipped depending on whether a condition
evaluates to TRUE or FALSE.

15
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming
c. Loop (Repetition) - The repetition/loop structure is the construct where
statements can be executed repeatedly until a condition evaluates to TRUE or
FALSE.
Example 1: An algorithm in adding two numbers.
1. Start
2. Declare variables num1, num2 and sum.
3. Read values num1 and num2.
4. Add num1 and num2 and assign the result to sum.
sum←num1+num2
5. Display sum
6. Stop

Example 2: An algorithm to calculate even numbers between 0 and 99


1. Start
2. I ← 0
3. Write I in standard output
4. I ← I+2
5. If (I <=98) then go to line 3
6. Stop

Example 3: An algorithm to find the largest value of any three numbers.


1: Start
2: Read/input A, B and C
3: If (A>=B) and (A>=C) then Max=A
4: If (B>=A) and (B>=C) then Max=B
5: If (C>=A) and (C>=B) then Max=C
6: Print Max
7: Stop

Pseudocode

Pseudocode (also known as Program Design Language) is a method of


describing computer algorithms using a combination of natural language and
programming language. Pseudocode is a "text-based” (algorithmic) design tool. It is
also an outline of a program written in a form that can easily be converted into real
programming statement but cannot be compiled or executed.

Rules for Pseudocode


a. Write only one statement per line - Each statement in your pseudocode
should express just one action for the computer.
b. Capitalize initial keyword - In the example above, READ and WRITE are in
capital letters. Some keywords that needs to be capitalized are: READ, WRITE,
IF, ELSE, ENDIF, WHILE, ENDWHILE, REPEAT, UNTIL

16
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

c. Indent to show hierarchy


• SEQUENCE: keep statements that are “stacked” in sequence all starting in
the same column.
• SELECTION: indent the statements that fall inside the selection structure,
but not the keywords that form the selection
• LOOPING: indent the statements that fall inside the loop, but not the
keywords that form the loop
d. End multiline structures - The ENDIF (or END whatever) always is in line
with the IF (or whatever starts the structure).
e. Keep statements language independent - avoid using the special features
of a programming language.
Example 4: Student's grade is greater than or equal to 60
IF student's grade is greater than or equal to 60
Print "passed"
ELSE
Print "failed"
ENDIF
Example 5: Compute the gross pay based on hours worked times hours
READ name, hourlyRate, hoursWorked, deductionRate
grossPay = hourlyRate * hoursWorked
deduction = grossPay * deductionRate
netPay = grossPay – deduction
WRITE name, grossPay, deduction, netPay
Example 6: Compute the gross pay based on hours worked times hours
READ name, hourlyRate, hoursWorked
grossPay = hourlyRate * hoursWorked
IF grossPay >= 100
deduction = grossPay * deductionRate
ELSE
deduction = 0
ENDIF
netPay = grossPay – deduction
WRITE name, grossPay, deduction, netPay

Flowchart

A flowchart is a schematic representation of an algorithm or a stepwise


process, showing the steps as boxes of various kinds, and their order by connecting
these with arrows. Flowcharts are used in designing or documenting a process or
program.

A flow chart, or flow diagram, is a graphical representation of a process or


system that details the sequencing of steps required to create output.

17
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

A flowchart is a picture of the separate steps of a process in sequential


order. There are basic symbols commonly used in flowcharting.

The following are some guidelines in flowcharting:

(a) In drawing a proper flowchart, all necessary requirements should be listed out in
logical order.

(b) The flowchart should be clear, neat and easy to follow. There should not be any
room for ambiguity in understanding the flowchart.

(c) The usual direction of the flow of a procedure or system is from left to right or top
to bottom.

(d) Only one flow line should come out from a process symbol.
or

18
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

(e) Only one flow line should enter a decision symbol, but two or three flow lines,
one for each possible answer, should leave the decision symbol.
(f) Only one flow line is used in conjunction with terminal symbol.

(g) Write within standard symbols briefly. As necessary, you can use the annotation
symbol to describe data or computational steps more clearly.

(h) If the flowchart becomes complex, it is better to use connector symbols to


reduce the number of flow lines. Avoid the intersection of flow lines if you want to
make it more effective and better way of communication.

(i) Ensure that the flowchart has a logical start and finish.

Example 7: Draw the flowchart for finding the average of two

numbers
19
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

Example 8: Draw a flowchart that will print Hello World 10 times


Application
You just learned about the steps in solving problems using Algorithm,
pseudocode and Flowchart. To enhance more of your critical thinking in solving logical
problems, other activities are below to fulfill your requirements of the operation.
Activity 2.1.2 Algorithms, Pseudocode, and Algorithm.
Write down the answer on how to address the various
problems. 1. Write an algorithm to convert the length in feet to
centimeter.

2. Write an algorithm that will read the two sides of a rectangle and calculate its
area.

20
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

3. Write a pseudo code to print the SUM of numbers from 3 to 9.


4. Write a pseudocode to calculate 24.

5. Draw a flowchart to log in to Facebook account based on the given algorithm.


a. Enter www.facebook.com in your browser. (I/O)
b. Facebook Home page loads (PROCESS)
c. Enter your Email ID and Password (I/O)
d. Is Email ID and Password Valid (DECISION)
if NO then
Log in error (PROCESS)
Go to step 3
else
Display Facebook Account (I/O)
Stop

21
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming
REFLECTION/LEARNING INSIGHTS

Write your insights from our lessons and activities in order to evaluate knowledge
and skills that you learned.
___________________________________________________________________
___________________________________________________________________
___________________________________________________________________
___________________________________________________________________
___________________________________________________________________
___________________________________________________________________
___________________________________________________________________
___________________________________________________________________
___________________________________________________________________
___________________________________________________________________
___________________________________________________________________

22
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

LESSON 2: PROGRAMMING LANGUAGE CONCEPTS


DURATION: 3 hours

INTRODUCTION
Several programming languages are implemented each year, but few
languages are becoming very popular that may be used in a career by a professional
programmer.
Programming languages are used to control computer or machine
performance. Computer programmers currently have many options to choose what
kind of language to use but there are a lot of differences between programming
languages.
Thus, this lesson will provide useful information about what are the different
types of programming languages, differences between programming languages and
programming language types.
OBJECTIVES
When you finish this lesson, you will be able to:
• Learn about useful programming languages
• Understand theoretical concepts in programming languages
• Become a better programmer in your own programming language

PRE-TEST
How about we assess your insight into the exercise by responding to the
accompanying questions:
1. What are the concepts of different programming languages?

LESSON PROPER/COURSE METHODOLOGY


Activity 2.2.1
This is a review of the previous subject that you took up last semester. Here
are some prompt exercises to analyze your insight in the lesson we will discuss later.
1. What is a program?
______________________________________________________________
______________________________________________________________
______________________________________________________________
2. What is a programming language?
______________________________________________________________
______________________________________________________________
______________________________________________________________
3. What is an interpreter?

23
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

______________________________________________________________
______________________________________________________________
______________________________________________________________

4. Give at least 3 example of programming language.


______________________________________________________________
______________________________________________________________
______________________________________________________________
5. What is Object oriented programming?
______________________________________________________________
______________________________________________________________
______________________________________________________________

Analysis
In order to better understand our lesson, you need to analyze and reflect on
your previous activities.
1. The above activities made me discover
______________________________________________________________
______________________________________________________________

2. It helped me understand and assess that


______________________________________________________________
______________________________________________________________

3. Now, I want to try and examine more on


______________________________________________________________
______________________________________________________________
______________________________________________________________

Abstraction
What is a Program?
Program is a common computer term that can be used as both a noun and a
verb. A program (noun) is executable software that runs on a computer. It is like a
script but is often much larger in size and does not require a scripting engine to run.
Instead, a program consists of compiled code that can run directly from the computer's
operating system.

24
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

What is a Programming Language?


A programming language is a notation designed to connect instructions to a
machine or a computer. Programming languages are mainly used to control the
performance of a machine or to express algorithms. The program can be divided into
two forms such as syntax and semantics. Some languages are defined by a SO
standard like C language.

The ABC’s of Programming- One should be familiarized with the following


terms in order to understand the different concepts in Programming.

A
Array is a group of related data values (called elements) that are grouped together.
All the array elements must be the same data type.
Program used to convert or translate programs written in assembly code to
machine code. Some users may also refer to assembly language or assembler
language as assembler.

B
Bitwise operators are used in programming for operating on the individual bits of
binary values.
A bug is a general term used to describe any unexpected problem with hardware or
software.

C
Code, which can be short for source code, is a term used to describe text that is written
using the protocol of a particular language, such as C, Java, Perl, PHP, or other
programming language by a computer programmer.

Compile is to transform a program written in a high-level programming language


from source code into object code. This can be done by using a tool called compiler.

A compiler reads the whole source code and translates it into a complete machine
code program to perform the required tasks which is output as a new file.

Computer Program
• A program is a set of instructions following the rules of the chosen language. •
Without programs, computers are useless.
• A program is like a recipe.
• It contains a list of ingredients (called variables) and a list of directions (called
statements) that tell the computer what to do with the variables.

Computer programming is the process of writing, testing,


debugging/troubleshooting, and maintaining the source code of computer programs.
This source code is written in a programming language like PYTHON, JAVA, Perl etc.

25
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

D
Debug refers to the process of examining and removing errors from a program's
source code.

F
A floating-point is a variable type that is used to store floating-point number values.
Examples of floating-point numbers are 1.23, 87.425, and 9039454.2.

G
Generations of Programming Language
• The first-generation languages, or 1GL, are low level languages that are machine
language.
• The second-generation languages, or 2GL, are also low-level languages that
generally consist of assembly languages.
• The third-generation languages, or 3GL, are high level languages such as C. •
The fourth-generation languages, or 4GL, are languages that consist of statements
like that in a human language. Fourth generation languages are commonly used in
database programming and scripts.
• The fifth-generation languages, or 5GL, are programming languages that contain
visual tools to help develop a program. A good example of a fifth-generation
language is Visual Basic.
A GUI is a graphical (rather than purely textual) user interface to a computer.
Elements of a GUI include textboxes, buttons, pull down menus, list and combo
boxes.

H
A high-level language is a computer programming language that isn't limited by the
computer, designed for a specific job, and is easier to understand. It is more like human
language and less like machine language.

I
Interpreter is a program that executes instructions written in a high-level language.
An interpreter reads the source code one instruction or line at a time, converts this line
into machine code and executes it.

An IDE or Integrated Development Environment is a software program that is


designed to help programmers and developers build software.

L
A loop describes the process of a software program or script repeats the same
instructions or processes the same information over and over until receiving the order
to stop.

26
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

N
Null defines a lack of value.

O
Object-oriented programming (OOP) is a programming language model organized
around "objects" rather than "actions" and data rather than logic. Historically, a
program has been viewed as a logical procedure that takes input

P
A programmer is someone who writes computer program. Computer programmers
write, test, and maintain programs or software that tells the computer what to do.

Programming Language - A vocabulary and set of grammatical rules (syntax) for


instructing a computer to perform specific tasks. There are types of Programming
Languages:
• Machine language is a collection of binary digits or bits that the computer reads
and interprets. Machine languages are the only languages understood by
computers.
• Assembly languages use keywords and symbols, much like English, to form a
programming language but at the same time introduce a new problem.
Assembly language programs are translated into machine language by a
program called an assembler.
• High-level languages allow us to write computer code using instructions
resembling everyday spoken language which are then translated into machine
language to be executed.

S
The source code consists of the programming statements that are created by a
programmer with a text editor or a visual programming tool and then saved in a file.

Structured programming (sometimes known as modular programming) is a subset


of procedural programming that enforces a logical structure on the program being
written to make it more efficient and easier to understand and modify.

V
A variable is a location capable of storing temporary data within a program. A void
can refer to a data type or object used in computer programming that does not have
a return a value or type.

Application
Just learn about the different language concepts in programming. To improve
their programming knowledge, here is an activity below that meets the requirements.

27
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

Activity 2.2.2 Programming Language Concepts.


Answer the following questions and encircle the letter of the correct answer.

1. A _________________is a computer programming language that isn't limited


by the computer, designed for a specific job, and is easier to understand. It is
more like human language and less like machine language.
a. computer language c. high level language
b. middle level language d. low level language

2. ______________is a program that executes instructions written in a high-level


language. It reads the source code one instruction or line at a time, converts
this line into machine code and executes it.
a. Interpreter c. Compiler
b. Assembler d. None of the choices
3. A __________is a set of instructions following the rules of the chosen
language.
a. compile c. code
b. semantics d. program
4. _______________is a collection of binary digits or bits that the computer
reads and interprets.
a. high level language c. computer language
b. programming language d. machine language
5. It keeps statements that are “stacked” in sequence all starting in the same
column.
a. compile c. code
b. semantics d. Sequence
6. There are ______ generations of computer language.
a. 4 c. 5
b. 6 d. 7
7. 7. ______________is a group of related data values (called elements) that
are grouped together.
a. Interpreter c. Compiler
b. Array d. None of the choices
8. A _____________ is a general term used to describe any unexpected
problem with hardware or software.
a. Interpret c. Compile
b. bug d. None of the choices
9. 9. _____________include textboxes, buttons, pull down menus, list and
combo boxes.
a. GUI c. PHP
b. IDE d. None of the choices
10. A vocabulary and set of grammatical rules (syntax) for instructing a computer
to perform specific tasks.
a. Programmer c. Dynamic Language

28
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

b. Programming Language d. None of the choices


11. ___________refers to the process of examining and removing errors from a
program's source code.
a. Debug c. Compile
b. bug d. None of the choices
12. A ____________is a location capable of storing temporary data within a
program.
a. Debug c. Compile
b. Bug d. Variable
13.Program used to convert or translate programs written in assembly code to
machine code.
a. Interpreter c. Compiler
b. Assembler d. None of the choices
14. __________________is a programming language model organized around
"objects" rather than "actions" and data rather than logic.
a. OOP c. IDE
b. GUI d. None of the choices
15.A _____________can refer to a data type or object used in computer
programming that does not have a return a value or type.
a. Debug c. Void - a
b. Bug d. Variable

REFLECTION/LEARNING INSIGHTS

To evaluate the knowledge and skills of this lesson, answer the following
question: 1. What is computer program?
______________________________________________________________
______________________________________________________________
______________________________________________________________

2. What are the three (3) types of programming language?


______________________________________________________________
______________________________________________________________
______________________________________________________________
______________________________________________________________
______________________________________________________________
______________________________________________________________ 3.
What are the Generation of Programming Language?
______________________________________________________________
______________________________________________________________
______________________________________________________________
______________________________________________________________
______________________________________________________________
______________________________________________________________

29
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

LESSON 3: BASICS OF PYTHON


DURATION: 6 HOURS

INTRODUCTION
In this lesson, you will be guided and introduced to what Python language is,
its brief history, and as well as their applications. You must understand its basics first
since it is one of your first step in creating programs that you might encounter and use
in the future. Learning how it works will give you a better scope of where you will be
heading at.
OBJECTIVES
At the end of this chapter, you will be able to:
✓ Learn the brief history of Python.
✓ Know the features of Python.
✓ Identify the different applications of Python.
✓ Remember the four reasons to choose Python as 1st Language in
programming.

PRE-TEST
Let’s us find out how much you already know about this topic. Please answer
the following questions. You may search the web or the previous lessons as reference
to your answer.
1. What is Object Oriented Programming?
___________________________________________________________________
___________________________________________________________________
___________________________________________________________________
2. What is a programming language?
___________________________________________________________________
___________________________________________________________________
___________________________________________________________________

3. Give at least five programming languages.


___________________________________________________________________
___________________________________________________________________
___________________________________________________________________
4. What is Python?
___________________________________________________________________
___________________________________________________________________
___________________________________________________________________

30
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

LESSON PROPER/COURSE METHODOLOGY


Activity 2.3.1
Before continuing with our lecture, how do we do a prompt exercise to analyze
your insight into the issues that we will look at later.
1. What is the output of this program?

a. “Hello World!” c. “Hello” “ World!”


b. Hello World! - a d. Error
2. These are intended for the person reading the code to better understand the
functionality of the program.
a. Comments – a c. null
b. Status d. Statement
3. This is used to print output on the screen.
a. cin c. if-else
b. cout – a d. while
4. A valid C++ program must have the main() function. The Parenthesis
indicate the start and the end of the function.
a. False – a b. True
5. The return 0; statement is the "return value" of the program. In simple
terms, the program ends with this statement.
a. True b. False - a
Analysis
In order to better understand our lesson, you need to analyze and reflect on
your previous activities.
1. The above activities made me recall
______________________________________________________________
______________________________________________________________ 2.
It helped me think about it and realize that
______________________________________________________________
______________________________________________________________ 3.
Now, I want to learn and understand more on
______________________________________________________________
______________________________________________________________

31
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

Brief History of Python

According to Wikipedia, Python is an interpreted, high-level, general-purpose


programming language. Created by Guido van Rossum and first released in 1991,
Python's design philosophy emphasizes code readability with its notable use of
significant whitespace. Its language constructs and object-oriented approach aim to
help programmers write clear, logical code for small and large-scale projects.[28]

Python is dynamically typed, and garbage collected. It supports multiple


programming paradigms, including structured (particularly, procedural), object
oriented, and functional programming. Python is often described as a "batteries
included" language due to its comprehensive standard library.

Fun fact. It wasn't named after a dangerous snake. Rossum was fan of a comedy
series from late seventies. The name "Python" was adopted from the same series
"Monty Python's Flying Circus".
History of Python
▪ Python was conceptualized by Guido Van Rossum in
the
late 1980s.
▪ Rossum published the first version of Python code
(0.9.0)
in February 1991 at the CWI (Centrum Wiskunde &
Informatica) in the Netherlands, Amsterdam.
▪ Python is derived from ABC programming language,
which
is a general-purpose programming language that had been
developed at the CWI.
▪ Rossum chose the name "Python", since he was a big fan of Monty Python's
Flying Circus.
▪ Python is now maintained by a core development team at the institute,
although Rossum still holds a vital role in directing its progress.
Release Dates of Different Versions
Version Release Data

Python 1.0 (first standard release) January 1994


Python 1.6 (Last minor version) September 5, 2000

Python 2.0 (Introduced list comprehensions) October 16, 2000


Python 2.7 (Last minor version) July 3, 2010

Python 3.0 (Emphasis on removing duplicative constructs December 3,


and module) 2008 September
Python 3.5 (Last updated version) 13, 2015

Features of Python
1. Easy to learn, easy to read and easy to maintain.
2. Portable: It can run on various hardware platforms and has the same interface
on all platforms.

32
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

3. Extendable: You can add low-level modules to the Python interpreter. 4.


Scalable: Python provides a good structure and support for large programs. 5.
Python has support for an interactive mode of testing and debugging. 6.
Python has a broad standard library cross-platform.
7. Everything in Python is an object: variables, functions, even code. Every object
has an ID, a type, and a value.
8. Python provides interfaces to all major commercial databases. 9. Python
supports functional and structured programming methods as well as OOP.
10.Python provides very high-level dynamic data types and supports dynamic type
checking.
11.Python supports GUI applications
12.Python supports automatic garbage collection.
13.Python can be easily integrated with C, C++, and Java.

Applications of Python

• Web Development :Google, Yahoo


• Games :Battlefield 2, Crystal Space
• Graphics :Walt Disney Feature Animation, Blender 3D
• Science :National Weather Service, NASA, Applied Maths
• Software Development :Nokia, Red Hat, IBM
• Education :University of California-Irvine, SchoolTool
• Government :The USA Central Intelligence Agency (CIA)
5 Reasons to choose Python as 1st Language
• Python is fun.: Python is a relatively
efficient
language, requiring fewer lines of code to
produce results.
• Python is easy to set up.: Some
languages,
such as Java or C#, have much higher
setup and
maintenance overhead.
• Python is not going away anytime soon. In
fact, Python has become the most frequently
used teaching language at major universities.
• Python is a tool of choice for doing some very big things. For instance:
YouTube, Google, Instagram, Pinterest, Quora, Reddit, Dropbox, Civilization

33
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

IV, and more. It’s also widely used for penetration testing, data analysis, scientific
computing, and more.
• Python jobs pay well, and python programmers are in high demand.

Python as Interpreted Language:


• Prototyping is faster.
• Debugging is on the spot.
• Source code is public (easy-to-understand vs. privacy).
• Execution is slower (in terms of microseconds-milliseconds).
• Cross CPU & Platform (OS) oriented.
• Requires less memory.
• Portable

• High-level programming language (English-keywords/Human Language keywords


oriented)

Quick Comparison: Compiled vs. Interpreted Language


34
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

Hybrid Language:
• Prototyping is faster.

• Debugging is on the spot.

• Source code is public (easy-to-understand vs. privacy).

• Could be Cross CPU & Platform (OS) oriented.

• Portable

• High-level programming language (English-keywords/Human Language


keywords oriented)
• Process: pre-compile to IL (Intermediate Language) then interpret/complete
compile via JIT (Just-In-Time) compiler.
Analysis
After learning its history and basic functions, let us have a deeper
understanding as we compare its coding with Java.
Python vs. Java : Code Examples

35
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming
Abstraction
After reading and learning the lesson, let us summarize up:
What is Python?
Python is a high-level programming language which is:
▪ Interpreted: It is processed at runtime by the interpreter.
▪ Interactive: You can use a Python prompt and interact with the interpreter
directly to write your programs.
▪ Object-Oriented: It supports Object-Oriented technique of programming. ▪
Beginner’s Language: A great language for the beginner-level
programmers and supports the development of a wide range of
applications.

36
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

An INTERPRETER is a computer program, which coverts each high-level


program statement into the machine code.

A COMPILER is a computer program that transforms code written in a high


level programming language into the machine code

➢ Compiler - It is a program which translates the human-readable code to a


language a computer processor understands (binary 1 and 0 bits).
➢ Both compiler and interpreters do the same job which is converting higher level
programming language to machine code.
➢ However, a compiler will convert the code into machine code (create an exe) before
program run. Interpreters convert code into machine code when the program is run.
2016- Most popular coding language 26.7%
• Java - 22.6,

• C++ - 9.9%
2017 - #1 in The 9 Most in-demand Programming Language.
• #2 - c++

• #4- java
2018 - Percentage growth of Python is 500 times more than it’s peer Languages.
• Python - 57.36%

• Java -37.09 %
2019 - Data job mentioning this skill set / skill set over the previous
year • Java - 6.62 - 63.30%

• Sql -5.86 - 76%

• linux - 4.10 - 76.60%

• Python - 3.99% - 96.90 %

ACTIVITY 2.3.2 – Basic of Python


Answer the following Question. Encircle the letter of the correct
answer: 1. Python is a high-level programming language.
a. True b. False
2. It is processed at runtime by the interpreter.
a. Compiled c. Interpreted
b. Arguments d. Null
3. You can use a Python prompt and interact with the interpreter directly to write
your programs.
a. Memory c. Statement
b. Interactive d. Comment
4. It supports Object-Oriented technique of programming.
a. Object-Oriented c. Compiled
b. Interpreted d. NOTC

37
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

5. Python is a great language for the beginner-level programmers and supports


the development of a wide range of applications.
a. True 8 b. False

REFLECTION/LEARNING INSIGHTS

In order to evaluate knowledge and skills, you learned from our lessons and
activities, write a brief insight below.
___________________________________________________________________
___________________________________________________________________
___________________________________________________________________
___________________________________________________________________
___________________________________________________________________
___________________________________________________________________
___________________________________________________________________

38
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

LESSON 4: PROGRAMMING PYTHON


DURATION: 6 HOURS

INTRODUCTION
In this lesson, you will start coding and debugging Python, you will be guided
in writing basic codes and providing simple output using it. The lesson will also tackle
how to use comments, prompts and reserved words as well as lines and indention.
OBJECTIVES
At the end of this chapter, you will be able to:
✓ Learn the two approach of programming.
✓ Know the reserved words.
✓ Create comments.
✓ Identify multiple statements on a single line.

PRE-TEST
Let’s us find out how much you already know about this topic. Please answer
the following questions. You may search the web or the previous lessons as reference
to your answer.
▪ Python was conceptualized by Guido Van ___________ in the late 1980s. ▪
Rossum published the first version of Python code (0.9.0) in ____________
1991 at the CWI (Centrum Wiskunde & Informatica) in the Netherlands ,
Amsterdam.
▪ Python is derived from _________ programming language, which is a general-
purpose programming language that had been developed at the CWI. ▪ Rossum
chose the name "Python", since he was a big fan of _____________ Flying
Circus.
▪ _____________ is now maintained by a core development team at the
institute, although Rossum still holds a vital role in directing its progress. ▪
____________: It can run on various hardware platforms and has the same
interface on all platforms.
▪ ____________:: You can add low-level modules to the Python interpreter. ▪
____________:: Python provides a good structure and support for large
programs.
▪ Python has support for an ____________: mode of testing and debugging. ▪
Python has a broad standard ____________: cross-platform.
▪ Everything in Python is an ____________:: variables, functions, even code.
Every object has an ID, a type, and a value.
▪ Python provides interfaces to all major commercial ____________:. ▪ Python
supports functional and structured programming methods as well as
____________:.

39
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

▪ Python supports ____________: applications


▪ Python supports automatic ____________:
▪ Python can be easily ____________: with C, C++, and Java.

LESSON PROPER/COURSE METHODOLOGY


Two Approach of Programming
In the world of programming, algorithms take the prime spotlight. These
complex mathematical and computational designs are used to find solutions to even
more complex programming issues. But that’s something we’re all aware of. However,
do you know how these algorithms are designed and created?
The Top-Down Approach

In the top-down approach, a complex algorithm is broken down into smaller


fragments, better known as ‘modules.’ These modules are then further broken down
into smaller fragments until they can no longer be fragmented. This process is called
‘modularization.’ However, during the modularization process, you must always
maintain the integrity and originality of the algorithm.

By breaking a bigger problem into smaller fragments, the top-down approach


minimizes the complications usually incurred while designing algorithms. Furthermore,
in this approach, each function in a code is unique and works independently of other
functions. The top-down approach is heavily used in the C programming language.

The Bottom-Up Approach

Contrary to the top-down approach, the bottom-up approach focuses on


designing an algorithm by beginning at the very basic level and building up as it goes.
In this approach, the modules are designed individually and are then integrated
together to form a complete algorithmic design.

So, in this method, each and every module is built and tested at an individual
level (unit testing) prior to integrating them to build a concrete solution. The unit testing
is performed by leveraging specific low-level functions.

What Are The Key Differences Between The Top-Down And The Bottom
Up Approaches?

Based on the core preferences and values of each methodology, we can chalk
out certain basic differences between the two. They are:

• While the top-down approach focuses on breaking down a big problem into
smaller and understandable chunks, the bottom-up approach first focuses on

40
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

solving the smaller problems at the fundamental level and then integrating them into
a whole and complete solution.
• The top-down approach is primarily used by structured programming languages
such as C, COBOL, Fortran. On the contrary, the bottom-up approach is preferred
by OOP languages such as C++, C#, Python, Java, and Perl.
• In the top-down approach, each module and submodule are processed separately,
and hence, they might contain redundant information. However, the bottom-up
approach relies on data encapsulation and data-hiding, thereby, minimizing
redundancy.
• The top-down approach doesn’t require the modules to have a well-established
line of communication among them, whereas, in the bottom-up approach, the
modules must have a certain degree of interaction and communication among them.
• While the top-down approach can be used in module documentation, debugging,
and code implementation, the bottom-up approach is primarily used in testing.

Thus, in conclusion, we can say that the top-down approach is rather the
conventional method that seeks to decompose a complex problem into smaller
fragments (from high-level specification to low-level specification), the bottom-up
approach works is just the opposite – it first concentrates on designing the
fundamental components of an algorithm and then moves up to a higher level to
achieve a complete result.

Two (2) approach of programming


1. Interactive Programming
2. Script Mode Programming

Interactive Programming – One should open the python program via command
prompt (windows) or terminal (other OS) after installed. To invoke interpreter w/o
passing script file/source code as a parameter, one should meet the following
prompt.

Example 1: Python 3.8.5 and


Python 2.7.14

41
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

If you had successfully installed Python 2 and included on your PATH


environmental variables (if Windows), typing “python” only would run the python
interpreter as “Example 1” above (excluding the following print code).

Example 2: print in
python 3.8.5
Type the following text at the Python prompt and press Enter: print (“Hello,
Python!”) and “Example 2” above will be the result.

Example 3: print in
python 2.7.14

If you are running Python 2, print “Hello, Python!”; will be the code to run will
have same result as “Example 2” but would render error if same syntax on Python 2
was used as the “Example 2” above.

Example 4: error
in syntax in python 3.8.5

Script Mode Programming – One should create a file having extension name of “.py”
that has “print “Hello, Python!” code in it. And put it on any location on your pc.
Technically, we saved “test.py” file on Users folder where it has the said code.

42
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

Example 5: Accessing test.py thru command prompt


Open the prompt/terminal and type “python test.py” (if python was installed having
a PATH included on environmental variables of your computer (Windows). It should
run the file “test.py” you created unless it is not on the same directory as shown on
“Figure 4” command prompt current directory line.

Reserved Words

Reserved words (also called keywords) are defined with predefined meaning
and syntax in the language. These keywords have to be used to develop programming
instructions. Reserved words can’t be used as identifiers for other programming
elements like name of variable, function etc.

Following is the list of reserved keywords in Python 3


And except lambda with

As finally nonlocal while

Assert false None yield

Break For not

Class From or

43
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming
Continue global pass

Def If raise

del import return

elif In True

else Is try

Python 3 has 33 keywords while Python 2 has 30. The print has been
removed from Python 2 as keyword and included as built-in function.

To check the keyword list, type following commands in interpreter −

>>> import keyword


>>> keyword.kwlist

Lines and Indention


Python Syntax - Python programming language is designed to be a highly
readable language. Python is one of the top ten in popular programming language. It
is high level language and it is an open source, meaning that it can serve as a
scripting language for web applications and it is commonly used in artificial
intelligence projects.
In the Python programming, the line contains only the following including the
spaces, tabs and the comment where it is considered as the blank line of the page and
the Python interpreter ignores it.
Syntax in English language is the arrangement of words and phrases to create
a meaningful sentence. It works similarly in Python because it determines how a
Python program will be logically written.
A Python program is read by a parser. Python was designed to be a highly
readable language. The syntax of the Python programming language is the set of rules
which defines how a Python program will be written.
Python was originally developed as a teaching language, but its ease of use
and clean syntax had led it to be embraced by beginners and experts alike. The
cleanliness of Python's syntax has led some to call it "executable pseudocode", and
indeed my own experience has been that it is often much easier to read and
understand a Python script than to read a similar script written in C.
44
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

Example 6: Sample Code

Python Indention
Indentation is one of the most important logic part of the program in different
languages esp. Python, it uses whitespace (spaces and tabs) to define program blocks
whereas other languages like C, C++ use braces ({}) to indicate blocks of codes for
class, functions or flow control. The number of whitespaces (spaces and tabs) in the
indentation is not fixed, but all statements within the block must be the indented same
amount. In the following program, the block statements have no indentation.

This is the proper way to implement Indentation, there is a condition before the
print(“Hello World”), it will become the output of the given condition that’s why the
Indention is very important part of the program.
Example 7: Sample Code with indentation

Example 8: Lines and Indentation

45
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming
Example 9: Lines and Indentation

Multi-line Statements
Statements in Python typically end with a new line. Python does, however,
allow the use of the line continuation character (\) to denote that the line should
continue.
Example 10: using continuation character ( \ )

Statements contained within the [], {}, or () brackets do not need to use the line
continuation character.
Example 11: using the square bracket ([ ])

Python does not really have a syntax for multiline comments. To add a
multiline comment, you could insert a # for each line:

46
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

sample code:
#This is a comment
#written in
#more than just one line
print("Hello, World!")

Or, not quite as intended, you can use a multiline string (Docstrings). Python
will ignore string literals that are not assigned to a variable, you can add a multiline
string (triple quotes) in your code, and place your comment inside it:

sample code:

"""
This is a comment
written in
more than just one line
"""
print("Hello, World!")

Quotation in Python

Quotation symbols are used to create string object in Python. Python


recognizes single, double and triple quoted strings. String literals are written by
enclosing a sequence of characters in single quotes ('hello'), double quotes ("hello")
or triple quotes ('''hello''' or """hello""").

>>> var1='hello'
>>> var1
'hello'
>>> var2="hello"
>>> var2
'hello'
>>> var3='''hello'''
>>> var3
'hello'
>>> var4="""hello"""
>>> var4
'hello'

If it is required to embed double quotes as a part of string, the string itself should
be put in single quotes. On the other hand, if single quoted text is to be embedded,
string should be written in double quotes.

>>> var1='Welcome to "Python training" from


Tutorialspoint' >>> var1
'Welcome to "Python training" from Tutorialspoint'

47
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming
>>> var2="Welcome to 'Python training' from Tutorialspoint"
>>> var2
"Welcome to 'Python training' from Tutorialspoint"
Python string functions are very popular. There are two ways to represent
strings in python. String is enclosed either with single quotes or double quotes. Both
the ways (single and double quotes) are correct depending upon the requirement.
Sometimes we must use quotes (single or double quotes) together in the same string,
in such cases, we use single and double quotes alternatively so that they can be
distinguished.

Example 12: Check below example and analyze the error

Explanation- It gives an invalid syntax error. Because single quote after “it” is
considered as the end of the string and rest part is not the part of a string.

Example 13: It can be corrected as:

Comments
Python has commenting capability for the purpose of in-code
documentation. ➢ Comments can be used to explain Python code.
➢ Comments can be used to make the code more readable.
➢ Comments can be used to prevent execution when testing code.

Example 14. Comments ( #) , Python will ignore them:

48
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

Multi- Line Comments


Python does not really have a syntax for multi-line comments. To add a
multiline comment, you could insert a # for each line:

Example 15. Multiline Comments (#) , Python will ignore

them:
Or, not quite as intended, you can use a multiline string (Docstrings). Python
will ignore string literals that are not assigned to a variable, you can add a
multiline string (triple quotes) in your code, and place your comment inside it:

Example 16. Using triple quotes (“””)

If the string is not assigned to a variable, Python will read the code, but then
ignore it, and you have made a multiline comment.

Prompt User Input


Your programs can prompt the user for input. Developers often have a need to interact
with users, either to get data or to provide some sort of result. Most programs today
use a dialog box as a way of asking the user to provide some type of input.

Taking input in Python


Python provides us with two inbuilt functions to read the input from the
keyboard. ➢ raw_input ( prompt )
- This function works in older version (like Python 2.x). This function takes
exactly what is typed from the keyboard, convert it to string and then return
it to the variable in which we want to store.

49
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

Example 17. Using raw_input() in python 2.7.14


➢ input ( prompt )
- This function first takes the input from the user and then evaluates the
expression, which means Python automatically identifies whether user
entered a string or a number or list. If the input provided is not correct, then
either syntax error or exception is raised by python.

Example 18. Using input() in python 3.8.5

NOTE:
➢ x/y is a variable which will get the string value, typed by user during the
execution of program.
➢ Typing of data for the raw_input() function is terminated by enter key.
➢ We can use raw_input() to enter numeric data also.

50
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

Example 19. Prompting for a value


Example 20. Prompting for numerical input

Definition and
Usage
How the input function works in Python :
➢ When input() function executes program flow will be stopped until the user has
given an input.
➢ The text or message display on the output screen to ask a user to enter input
value is optional i.e. the prompt, will be printed on the screen is optional. ➢ A
prompt is a string, representing a default message before the input. ➢ Whatever
you enter as input, input function converts it into a string. if you enter an integer
value still input() function convert it into a string. You need to explicitly convert it
into an integer in your code using typecasting.

Example 21. Printing input value


51
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

Example 22. Printing input value

Multiple Statements on a Single Line


The semicolon ( ; ) allows multiple statements on the single line given that neither
statement starts a new code block. Here is a sample snip using the semicolon – import
sys; x = ‘bsu’; sys.stdout.write(x + ‘\n’)

Suites
A group of individual statements, which make a single code block are called suites
in Python. Compound or complex statements, such as if, while, def, and class require
a header line and a suite.
Header lines begin the statement (with the keyword) and terminate with a colon ( : )
and are followed by one or more lines which make up the suite. If expression:
#Suite / code block
Elif expression:
#Suite / code block
Else:
#Suite / code block
Code #code outside If-Elif condition
52
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

Example 23. Using list.append(elem)

Example 23. Using list.insert(index, elem)

Example 24. Using list.remove(elem)

Analysis
After learning its history and basic functions, let us have a deeper
understanding in coding Python.
Python Line Structures
A physical line is a sequence of characters terminated by an end-of-line sequence.
In windows it is called CR LF or return followed by a linefeed and in Unix, it is called
LF or linefeed. A line contains only spaces, tabs, form feeds possibly a comment is
known as a BLANK LINES, and Python interpreter ignores it. A Python program is
divided into a few logical lines and every logical line is terminated by the token
NEWLINE. A logical line is created from one or more physical lines.
53
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

Example 25. Line Structures

Joining Two Lines


A physical line ends with a backslash characters (\) and not a part of a string literal
or comment then it can join another physical line. When you want to write a long code
in a single line you can break the logical line in two or more physical lines using
backslash character (\).
Example 26. Joining Two Lines

Multiple Statements on a Single Line


You can write two separate statements into a single line using a semicolon (;)
character between two lines.
Example 24. Multiple Statement on a Single Line

54
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

Execute Python Syntax


Python syntax can be executed by writing directly in the Command Line. To
execute the code you must save your file in .py, it is the file name of Python then go to
cmd and find the path where the file is located. The print command in Python must
only in a small letter. One of the most important skills you need to build as a Python
developer is to be able to run Python scripts and code. This is going to be the only way
for you to know if your code works as you planned. It’s even the only way of knowing
if your code works at all. This step-by-step tutorial will guide you through a series of
ways to run Python scripts, depending on your environment, platform, needs, and skills
as a programmer.
Example 27. Sysntax

Quotation in Python
Python accepts single ('), double (") and triple (''' or """) quotes to denote
string literals, as long as the same type of quote starts and ends the string. The
triple quotes are used to span the string across multiple lines. Example 28.
Quotation in Python

Python Comments
Comments start with the hash (#) character in Python. All character or symbols
after the hash symbol are considered part of the comment. The comment is not the
part of the main program, but it is a helping tool in every program to know how a block
of codes functions because comments are meant to explain code.
The Python Comment is a programmer-readable explanation or annotation in
the source code of a computer program. Comments are text notes added to the
program to provide explanatory information about the source code. They are used in
a programming language to document the program and remind programmers of what
tricky things they just did with the code and also help the later generation for
understanding and maintenance of code. The compiler considers these as non-

55
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

executable statements. Different programming language uses a different way of


including the comments in the source code.
Example 29. Python Comment
Python block comments
The Python Block Comment is indented at the same level as the code block. To
write a block comment, it should start with a single hash (# ) sign followed by a single
space and comment. It can be used a block comment to explain the code that follows
it. A block comment is indented at the same level as the code block.
a. Python inline comments
The Python Inline Comments happens if a comment is placed on the same line
as a statement, it is called an inline comment. Similar to the block comment, an inline
comment begins with a single hash (# ) sign and followed by a space and comment.
It is recommended that an inline comment should separate from the statement
at least two spaces. The following example demonstrates an inline comment. b.
Python documentation string or docstrings

A documentation string is a literal string that can put as the first statement in a
function, module, class, or method definition. Different from a regular comment,
documentation string can be accessed at run-time using obj.__doc__ attribute where
obj is the name of function, module or class, etc. Documentation string is also used to
generate documentation automatically. Documentation string is also known as
docstrings. Python provides two kinds of docstrings: one-line docstrings and multi-line
docstrings.
One-line docstrings
One-line docstring fits in one line begins with triple quotes and ends with triple
quotes. There should not have a blank line either before or after the one-line
docstring.
c. Python multiline comments.

As its name implies, multi-line docstring can span multiple lines. Just like one
line docstring, the first line of multi-line docstring is a summary, followed by a blank
line and of course more descriptions underneath.

56
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

Example 30. Block of Comment


Abstraction
After reading and learning the lesson, let us summarize up:

When the program is getting bigger and more complicated, it is getting difficult
to read and maintain. For these reasons, it is a good practice to put some
documentations or notes into your code. These notes are called comments.

The code only can tell you how it does but cannot tell you why it does so.
However, your comment can do that. You use comments to explain the formulas,
complex algorithms and sophisticated business logic.

Python comment begins with a hash or pound (#) sign and continues to the end
of the line. It is important to note that Python interpreter ignores comments when it
interprets the code.

Python provides three kinds of comments including block comment, inline


comment and documentation string.

Python block comments

You use a block comment to explain the code that follows it. A block comment
is indented at the same level as the code block. To write a block comment, you start
with a single hash (# ) sign followed by a single space and comment.

Python inline comments

If a comment is placed on the same line as a statement, it is called an inline


comment. Similar to the block comment, an inline comment begins with a single hash
(# ) sign and followed by a space and comment.

It is recommended that an inline comment should separate from the statement at


least two spaces. The following example demonstrates an inline comment.

57
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

Python documentation string or docstrings

A documentation string is a literal string that you put as the first statement in a
function, module, class, or method definition. Different from a regular comment,
documentation string can be accessed at run-time using obj.__doc__ attribute where obj
is the name of function, module or class, etc.

Documentation string is also used to generate documentation automatically.


Documentation string is also known as docstrings.

Python provides two kinds of docstrings: one-line docstrings and multi-line


docstrings.

One-line docstrings

One-line docstring fits in one line begins with triple quotes and ends with triple
quotes. There should not have a blank line either before or after the one-line
docstring.

Multi-line docstrings

As its name implies, multi-line docstring can span multiple lines. Just like one
line docstring, the first line of multi-line docstring is a summary, followed by a blank
line and of course more descriptions underneath.

Python multiline comments

Python does not support multiline comments like C/C++ or Java. However,
there is nothing to stop you to use multi-line docstrings as multiline comments. This is
also mentioned by Guido van Rossum, the creator of Python.

It is important to keep you comment clear, concise and explanatory. The goal
is to save time and energy for maintenance developers who will work on the code.

REFLECTION/LEARNING INSIGHTS

In order to evaluate knowledge and skills, you learned from our lessons and
activities, write a brief insight below.
___________________________________________________________________
___________________________________________________________________
___________________________________________________________________
___________________________________________________________________
___________________________________________________________________
___________________________________________________________________
___________________________________________________________________
___________________________________________________________________

58
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

FINAL REQUIREMENT for this Lesson

After finishing the lesson and answer problems and activities given from the start. For
your activity to be recorded, you pass it on time and please fill up the following details:
Name (LN,FN,MI) Year/Section Activity No. Grade / Score

Average Score

POST-TEST

Answer the following question by encircle the letter of the correct


answer: 1. What is the standard terminal symbol for a flowchart?
a. diamond c. circle
b. oval d. square
2. Which of the following is a pictorial representation of an algorithm?
a. Pseudo code c. Program
b. Algorithm d. Flowchart
3. A benefit of using flowcharts is:
a. They help you program faster c. They write the program for you b. They
help you program d. They help you visualize the instructions 4. A labeled
connector for use when the target is on another page. Represented as a -
shaped.
a. input/output c. terminal
b. off-page connector d. on-page connector

5. What is printed by the following algorithm?


SUM = 0
N = 20
WHILE N < 30 DO
SUM = SUM + N
PRINT N, SUM
N=N+3
ENDWHILE
a. 20, 20, 23, 43, 26, 69, 98 c. 20, 23, 43, 26, 69, 29, 98 b. 20, 20,
23, 43, 26, 69, 29 d. 20, 20, 23, 43, 26, 69, 29, 98 6. What are the
different steps in solving problems?
a. Algorithm, pseudocode, flowchart c. Start, Process, End
b. Branching, Decision, Repetition d. NOTC

59
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

7. It is the process of writing, testing, debugging/troubleshooting, and maintaining


the source code of computer programs.
a. Computer Science c. Communication State
b. Computer programming d. Null State
8. This is an interpreted, high-level, general-purpose programming language.
a. Python c. C++
b. C# d. VB.NET
9. This is a programming language model organized around "objects" rather than
"actions" and data rather than logic.
a. OOP c. IDE
b. GUI d. JAVA
10. These are symbols that are used to create string object in
Python. a. Less Than c. Quotation
b. Greater Than d. Assignment operator

REFERENCES

LESSON 1

➢ (n.d.). ALGORITHMS AND FLOWCHARTS - Academia.edu. Retrieved August


14, 2020, from (n.d.). What is programming? - Introduction to programming -
KS3 .... Retrieved August 14, 2020, from
https://www.bbc.co.uk/bitesize/guides/zts8d2p/revision/1
➢ ((2016, December 10). Algorithm, Pseudocode and Flowchart - BrainKart.
Retrieved August 14, 2020, from https://www.brainkart.com/article/Algorithm,-
Pseudocode-and-Flowchart_6945/
➢ (n.d.). Introduction to Programming - UK Data Service. Retrieved August 14,
2020, from
https://ukdataservice.ac.uk/media/604674/introprogrammingworkbook.pdf
➢ (n.d.). Introducing pseudocode - FutureLearn. Retrieved August 14, 2020, from
https://www.futurelearn.com/courses/block-to-text-based
programming/0/steps/39492
➢ (n.d.). 2.3. Introduction to Programming - FreeBSD. Retrieved August 14,
2020, from https://www.freebsd.org/doc/en_US.ISO8859-1/books/developers
handbook/tools-programming.html
➢ (2016, September 23). Algorithm, Flowchart and Program code to print the
larger of .... Retrieved August 14, 2020, from
https://progincse.blogspot.com/2016/09/write-program-in-c-to-print-larger
of.html?m=1
➢ https://www.academia.edu/7857144/ALGORITHMS_AND_FLOWCHARTS

LESSON 2

➢ (2015, January 8). Python Tip: Validating user input as number (Integer) | 101
.... Retrieved August 14, 2020, from https://www.101computing.net/number
only/

60
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

➢ (2019, December 9). Types and Differences between Programming


Languages. Retrieved August 14, 2020, from
https://www.typesnuses.com/types-of-programming-languages-with
differences/
➢ (2008, January 31). Program Definition - TechTerms. Retrieved August 14,
2020, from https://techterms.com/definition/program
➢ (n.d.). Overview of Programming Language Concepts. Retrieved August 14,
2020, from https://cs.lmu.edu/~ray/notes/plconcepts/
➢ (2017, November 27). Programming Languages and Systems. Retrieved
August 14, 2020, from https://link.springer.com/content/pdf/10.1007%2F978-3-
319-71237-6.pdf
➢ (n.d.). (PDF) Programming language concepts —Third edition .... Retrieved
August 14, 2020, from
https://www.academia.edu/34220053/Programming_language_concepts_Thir
d_edition

LESSON 3

➢ Mueller J.P. (2014), “Beginning Programming With Python-For Dummies”,


John Wiley & Sons, Inc.
➢ Liang, Y. D. (2011), “Introduction to Java Programming”, 8th edition, Prentice
Hall
➢ Wu, C. T. (2008). “A Comprehensive Introduction to Object-Oriented
Programming with Java “, McGraw Hill
➢ Zukowski, J (2005), “The Definitive Guide to Java Swing”, 3rd edition,
Springer-Verlag New York, Inc., ISBN (pbk): 1-59059-447-9

LESSON 4 – Other Reading Materials

➢ https://www.zentut.com/python-tutorial/python-comments/
➢ https://en.wikipedia.org/wiki/Python_(programming_language) ➢
https://www.tutorialspoint.com/What-are-different-types-of-quotes-in-Python ➢
https://towardsdatascience.com/single-double-and-triple-quotes-in-python
7ceea990baf
➢ https://stackoverflow.com/questions/9050355/using-quotation-marks-inside
quotation-marks
➢ https://realpython.com/python-comments-guide/

GLOSSARY

docstring - A string that appears as the lexically first expression in a module, class
definition or function/method definition is assigned as the __doc__ attribute of the
object where it is available to documentation tools or the help() built-in function.

61
OOP Unit 2: Review, Programming Concepts, Basic of Python and Programming

interactive - Python has an interactive interpreter which means you can enter
statements and expressions at the interpreter prompt, immediately execute them and
see their results.
interpreted - Python is an interpreted language, as opposed to a compiled one,
though the distinction can be blurry because of the presence of the bytecode
compiler. object - Any data with state (attributes or value) and defined behavior
(methods). object oriented - Programming typified by a data-centered (as opposed
to a function centered) approach to program design.
triple-quoted string - A string that is bounded by three instances of either the double
quote mark (") or the single quote mark (').
type - A "sort" or "category" of data that can be represented by a programming
language.
whitespace - The unconventional use of space characters (' ') to control the flow of a
program.

ANSWER KEY
c 10.
9.a
8.a
7.b
6.a
5.d
4.b
3.d
2.d
1.b

62

You might also like