0% found this document useful (0 votes)
16 views137 pages

Didactic Guide (Programming) Fifth Semester

This document is a student teaching guide for the development of information systems at Tabasco High School, focusing on programming and systems development. It aims to equip students with both theoretical knowledge and practical skills by engaging them in creating information systems relevant to their educational context. The guide emphasizes the importance of becoming producers of information and fostering collaboration and critical thinking among students.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views137 pages

Didactic Guide (Programming) Fifth Semester

This document is a student teaching guide for the development of information systems at Tabasco High School, focusing on programming and systems development. It aims to equip students with both theoretical knowledge and practical skills by engaging them in creating information systems relevant to their educational context. The guide emphasizes the importance of becoming producers of information and fostering collaboration and critical thinking among students.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 137

Systems Development

Student Teaching Guide

Information Systems
Page 151
COBATAB
TABASCO HIGH SCHOOL
TABASCO
“Education that generates
change”

Development of
Systems
i Didactic Guide 5th
semester

STUDENT DATA

Name:

Squad:

Cluster Shift:
:
“Education that generates change

TABASCO HIGH SCHOOL

MTRO. ERASMO MARTINEZ RODRIGUEZ


Managing director

L. CP SONIA LOPEZ LEFT


Academic Director

MTRA. Giselle Olivares Morales


Deputy Director of Academic Planning

LIC. ALLAN LOPEZ GALLEGOS


Department of Job Training

TRAINING IN INFORMATION AND COMMUNICATION TECHNOLOGIES


MODULE III. Systems development.
SUBMODULE 2: Programming.
EDITION. July 2021

The following people participated in the production of this material:


MATI. Beatriz Mazariego Narvaez
Mtra. Flower by Maria Sanchez Mena
Mtra. Griselda Elizabeth Hernandez Magana.
Mtro. Ventura Gutierrez Cabrera
LC Abel de la Cruz Hernandez
Mtro. Marcial Vidal Cruz
Mtra. Gabriela Zurita Rangel

Reviewed by:
Mtro. Cristy Miguel Selvan Garcia
LIA Karina del Carmen Gomez Lopez
Mtro. Jorge Alberto Almeida Alejandro

This material was prepared under the coordination and supervision of the Academic Directorate of
College of Bachelors of the State of Tabasco
www.cobatab.edu.mx

Choca Walk No. 1000 Col. Tabasco 2000, CP 86035 Villahermosa, Tabasco, MX
Tel.+52 (933)3 16 93 11
CO BATA
TABASCO B
“Education that generates
change”

CONTENT

The following people participated in the production of this material:......................3


Reviewed by:.............................................................................................................3
Presentation..........................................................................................................................8
Generic Competencies..........................................................................................................9
1. He knows and values himself and approaches problems and challenges taking into
account the objectives he pursues.............................................................................9
2. He is sensitive to art and participates in the appreciation and interpretation of its
expressions in different genres..................................................................................9
3. Choose and practice healthy lifestyles...........................................................9
4. Listen, interpret and send relevant messages in different contexts using appropriate
media, codes and tools..............................................................................................9
Think critically and reflectively................................................................................1
6. Supports a personal position on topics of general interest and relevance, considering
other points of view in a critical and reflective manner............................................1
Learn independently..................................................................................................1
7. Learn through initiative and self-interest throughout life..............................1
Works collaboratively...............................................................................................1
8. Participate and collaborate effectively in diverse teams................................1
9. Participate with a civic and ethical conscience in the life of your community, region,
Mexico and the world................................................................................................2
10. Maintains a respectful attitude towards interculturality and the diversity of beliefs,
values, ideas and social practices..............................................................................2
11. Contribute to sustainable development in a critical way, with responsible actions. 2
Basic Professional Competencies.........................................................................................2
Field: Information and Communication Technology.......................................................2
Focus of Discipline...............................................................................................................3
Disciplinary Field: Communication.................................................................................6
Module III Systems Development......................................................................................12
Purpose of the Module....................................................................................................12
Expected Learning Outcomes.........................................................................................12
Diagnostic evaluation.....................................................................................................21
What is programming logic?...................................................................................27
Rules for creating diagrams.....................................................................................24
For example:............................................................................................................34
Example: Sum of 2 numbers represented by A AND B.........................................35
If logical expression Then.......................................................................................41
Simple decision structure:.......................................................................................42
Double decision structure:.......................................................................................42
Multiple decision structure:.....................................................................................43
➢ Iterative Structure For (FOR)..........................................................................46
➢ Iterative Structure Repeat...............................................................................47
Some programming languages................................................................................54
Data types and structures.........................................................................................48
Instructions..............................................................................................................48
Flow control............................................................................................................56
Take a photo of the activity as evidence of your solution.......................................57
Questions to answer the word search......................................................................57
Programming...........................................................................................................57
References...............................................................................................................60
4.1. - Structured programming........................................................................53
Python example.......................................................................................................61
Functions:................................................................................................................61
Example of a function in Python.............................................................................55
Classes, Objects and Instances................................................................................56
1 .- Encapsulation................................................................................................57
2 .- Abstraction....................................................................................................57
3 .- The inheritance.............................................................................................57
4 .- Polymorphism...............................................................................................57
The features are summarized below:.......................................................................69
5.1 Development environments.............................................................................71
Installing Python for Windows 10..........................................................................71
Installation of Mu....................................................................................................72
CO BATA B............................................................................................................74
5.2. Variables.......................................................................................................74
The input() function................................................................................................75
Example:..................................................................................................................75
Enter data of different types....................................................................................76
Entering data with error (exceptions) capture.........................................................76
Comments................................................................................................................76
Examples: x = -4...............................................................................................77
y = 20.......................................................................................................................77
Examples: x = 3.5502.......................................................................................77
z = -35-59................................................................................................................77
Examples: x = 3 + 6j.........................................................................................78
y = 5j........................................................................................................................78
Type of chains.........................................................................................................79
Types of booleans....................................................................................................79
x = True...................................................................................................................79
y = False..................................................................................................................79
5.3 Operators...............................................................................................................80
Arithmetic operators................................................................................................80
Python Comparison Operators................................................................................71
Python Logical Operators........................................................................................71
5.4 Constants...............................................................................................................72
CO BATA B............................................................................................................80
5.5 Reserved words.....................................................................................................80
CO BATA B............................................................................................................74
6.1 If statement:.....................................................................................................87
The syntax of the if construct is as follows:............................................................87
if condition:.............................................................................................................87
FLOWCHART: IF STATEMENT..........................................................................89
running the program will not print output...............................................................90
6.2. - IF…Else statement:....................................................................................91
Syntax of the if ... else ... conditional statement......................................................91
6.3. - if Elif else statement...................................................................................92
CO BATA B............................................................................................................97
Python has two cyclic structures:............................................................................98
7.1 WHILE cyclic structure...................................................................................98
Structure of WHILE:...............................................................................................98
Example: Generate a counter from 1 to 10 and print the result..............................98
While Infinite..........................................................................................................99
Break.......................................................................................................................99
7.2. - FOR cyclic structure................................................................................101
FOR structure:.......................................................................................................101
Result.....................................................................................................................102
References.............................................................................................................107
I b —....................................................................................................................................101
Example 1..............................................................................................................108
Arrangements............................................................................................................117
Create arrangements..............................................................................................111
Instructions:...........................................................................................................121
References:............................................................................................................122
Graphical interfaces with Python 3.......................................................................117
Reference...............................................................................................................120

Page 1
“Education that generates change”

Presentation

The purpose of this teaching guide is to guide the student in acquiring knowledge in the development of
information systems.
In the technological world we currently live in, we must not only be consumers of information; we must change
our perspective and become producers of it.
This is why the Information Systems submodule proposes introducing students to this new perspective, starting
from the needs of their own educational institution, by creating an information system for the school library or
their community.
The student is guided step by step in the acquisition of theoretical knowledge and in its application, through the
methodology of systems development in the didactic situation called: “My library is great”.
In this way, generic skills in the use of ICT and the willingness to work collaboratively are strengthened, as well
as professional skills by proposing their own information system according to the needs of their educational
context, thereby making the student see one of the job opportunities that exist.
We hope that this guide will be useful for our educational community and will be enriched by your
contributions.

Paseo la Choca No 1000 Col 'j abasco 200 (Page 2


36035 Villahermosa * 1. abasco MX
Tel.+52 (933)3 16 93 11
COBATAB
TABASCO HIGH SCHOOL

“Education that generates change”

TABASCO Generic Competencies


He is self-determined and takes care of himself.

1. He knows and values himself and approaches problems and challenges taking into account the objectives
he pursues.

CG1.1 Faces the difficulties that arise and is aware of his/her values, strengths and weaknesses.
CG1.2 Identifies his/her emotions, manages them constructively and recognizes the need to ask for support
when faced with an overwhelming situation.
CG1.3 Choose alternatives and courses of action based on supported criteria and within the framework of a life
project.
CG1.4 Critically analyze the factors that influence decision-making.
CG1.5 Accepts the consequences of his/her behavior and decisions.
CG1.6 Manage available resources taking into account the restrictions to achieve goals.

2. He is sensitive to art and participates in the appreciation and interpretation of its expressions in different
genres.
CG2.1 Values art as a manifestation of beauty and expression of ideas, sensations and emotions.
CG2.2 Experience art as a shared historical fact that enables communication between individuals and cultures in
time and space, while developing a sense of identity.
CG2.3 Participate in art-related practices.

3. Choose and practice healthy lifestyles.


CG3.1 Recognizes physical activity as a means for physical, mental and social development.
CG3.2 Make decisions based on the assessment of the consequences of different consumer habits and risky
behaviors.
CG3.3 Cultivate interpersonal relationships that contribute to their human development and that of those
around them.

Expresses and communicates.

4. Listen, interpret and send relevant messages in different contexts using appropriate media, codes and
tools.
CG4.1 Express ideas and concepts through linguistic, mathematical or graphical representations.
CG4.2 Applies different communication strategies depending on who the interlocutors are, the context in which
they find themselves and the objectives they pursue.
CG4.3 Identify key ideas in a text or oral speech and draw conclusions from them.
CG4.4 Communicates in a second language in everyday situations.
CG4.5 Manage information and communication technologies to obtain information and express ideas.
Think critically and reflectively.

5. Develops innovations and proposes solutions to problems based on established methods.


CG5.1 Follow instructions and procedures thoughtfully, understanding how each step contributes
to achieving a goal.
CG5.2 Organize information according to categories, hierarchies and relationships.
CG5.3 Identify the core systems and rules or principles underlying a range of phenomena.
CG5.4 Construct hypotheses and design and apply models to test their validity.
CG5.5 Synthesizes evidence obtained through experimentation to produce conclusions and
formulate new questions.
CG5.6 Use information and communication technologies to process and interpret information.

6. Supports a personal position on topics of general interest and relevance, considering other
points of view in a critical and reflective manner.
CG6.1 Choose the most relevant sources of information for a specific purpose and discriminate
between them according to their relevance and reliability.
CG6.2 Evaluate arguments and opinions and identify biases and fallacies.
CG6.3 Recognizes own biases, modifies points of view when faced with new evidence, and
integrates new knowledge and perspectives into the available body of knowledge.
CG6.4 Structure ideas and arguments in a clear, coherent and synthetic manner.

Learn independently.

7. Learn through initiative and self-interest throughout life.


CG7.1 Define goals and monitor their knowledge construction processes.
CG7.2 Identify the activities that are of least and greatest interest and difficulty, recognizing and
controlling their reactions to challenges and obstacles.
CG7.3 Articulates knowledge from various fields and establishes relationships between them and
their daily life.

Works collaboratively.

8. Participate and collaborate effectively in diverse teams.


CG8.1 Propose ways to solve a problem or develop a team project, defining a course of action with
specific steps.
CG8.2 Provides open-minded opinions and considers the opinions of others thoughtfully.
CG8.3 Assume a constructive attitude, consistent with the knowledge and skills available within
different work teams.

— ' === ' ormanaos

Page 1
Participate responsibly in society.

9. Participate with a civic and ethical conscience in the life of your community, region, Mexico
and the world.
CG9.1 Favors dialogue as a mechanism for conflict resolution.
CG9.2 Make decisions in order to contribute to the equity, well-being and democratic development
of society.
CG9.3 Knows his rights and obligations as a Mexican and member of different communities and
institutions, and recognizes the value of participation as a tool to exercise them.
CG9.4 Contributes to achieving a balance between individual interest and well-being and the
general interest of society.
CG9.5 Acts in a proactive manner in the face of social phenomena and stays informed.
CG9.6 Notes that phenomena that develop at local, national and international levels occur within
an interdependent global context.

10. Maintains a respectful attitude towards interculturality and the diversity of beliefs, values,
ideas and social practices.
CG10.1 Recognizes that diversity takes place in a democratic space of equal dignity and rights for all
people, and rejects all forms of discrimination.
CG10.2 Engage in dialogue and learn from people with different viewpoints and cultural traditions
by placing their own circumstances in a broader context.
CG10.3 Assume that respect for differences is the principle of integration and coexistence in local,
national and international contexts.

11. Contribute to sustainable development in a critical way, with responsible actions.


CG11.1 Adopt an attitude that favors the solution of environmental problems at local, national and
international levels.
CG11.2 Recognize and understand the biological, economic, political and social implications of
environmental damage in an interdependent global context.
CG11.3 Contributes to achieving a balance between short- and long-term interests in relation to
the environment.

Basic Professional Competencies


Field: Information and Communication Technology

BASIC PROFESSIONAL COMPETENCES CLUE


1. Integrate digital information by creating electronic documents, CPBTIC1
using application software, such as word processors and image editors, responsibly and
creatively in work, school and everyday life settings.

Page 2
2. Prepares information through data manipulation and formulas, CPBTIC2
creating graphics in a spreadsheet application, creatively and innovatively solving situations in
various environments and contexts.
3. It proposes the use, creation and administration of electronic platforms of CPBTIC3
consultation, communication and distribution of multimedia content, proposing virtual
communities that allow communication, promoting self-learning in an innovative environment in
its different contexts.
4. Develops corrective actions for equipment operation problems CPBTIC4
computing, through the application of preventive and corrective maintenance according to the
manufacturer's specifications, prolonging the useful life of the equipment, showing responsibility
and initiative in various areas.
5. Proposes the design of information systems, based on the analysis of the CPBTIC5
user needs, allowing for responsible and innovative problem solving in different contexts.
6. Build organizational information systems by coding and compiling relevant algorithmic
instructions using programming languages and databases to meet the functionality and
performance requirements established in the design of information systems, assuming
frustration as part of the process in work, educational and everyday life environments.
7. Build creative and functional websites using web design software, CPBTIC7 to transmit
diverse electronic information on a large scale in a responsible and empathetic way in work,
educational and everyday life contexts.
8. Create various advertising graphic resources using design software, CPBTIC8
allowing their publication in digital and print media to communicate ideas or emotions
applicable to work, school and everyday life contexts, in an ethical and innovative environment,
showing flexibility and openness to different points of view

Focus of Discipline

The training in Information and Communication Technologies belongs to the disciplinary field of
Communication, its purpose is to develop in the students the communicative, verbal and non-
verbal skills to express themselves through various codes and language tools through different
information technologies. On the other hand, Information and Communication Technologies are
linked in an interdisciplinary way with both the field of Mathematics and Communication, since
they provide the elements for problem solving through algorithms and programming.

The general purpose of Information and Communication Technologies training is: To develop the
ability to propose solutions to problems in the work and school context, through the application of
Information and Communication Technologies, in a creative and innovative way, with an ethical
and responsible stance as a digital citizen.

The use of Information and Communication Technologies, from this training, highlights the
advanced management of software and hardware applications for solving problems in different
areas of daily life, developing methodological, creative and communicative aspects, without
forgetting a proactive behavior for personal benefit and within society.

The training in Information and Communication Technologies seeks to develop in students


professional skills in the areas of office applications, hardware elements, communications through
computer networks, systems development and design software, without forgetting the promotion
of generic skills, interdisciplinarity and the cross-cutting axes of labor linkage, Entrepreneurship as

Page 3
well as the continuation of their studies at a higher level.

In the curricular context of the training in Information and Communication Technologies, the
content is divided into four modules that are taught from the third semester with a workload of 7
hours per week, each module is made up of two submodules that seek to develop the
management of office applications that allow the creation of electronic documents with advanced
features using the word processor and the spreadsheet, create and participate in virtual
communities for the exchange of information including the educational field, apply maintenance to
the computer equipment; for the development of systems based on databases and programming,
through the creation of web pages and design software to communicate ideas and information, in
the work and school environment.

All these skills enable graduates to enter the workforce or to develop independent production
processes in accordance with their professional interests or the needs of their social environment
as an assistant in the following areas:

administrative, technical support, systems area, advertising, and others, in different public and
private institutions.

The teaching of Information and Communication Technology Training in youth job training, based
on the Technical Standards of Labor Competence (NTCL) of the National Council for Standardization
and Certification of Labor Competencies (CONOCER) becomes a first-order need to meet the
demands of the productive sectors, to have qualified personnel that allows developing the
potential of their organizations by promoting products and services both in the national and
international markets, in addition to providing basic technical tools to students graduating from
high school, which will allow them to overcome borders and enter the global world through
information and communication technologies (ICT'S), in addition to the use of learning and
knowledge technologies (TAC'S).

CINF0376.01 Preparation of documents and communication through the use of advanced features
of computer applications

UINF0650.01 Preserve computer equipment, supplies, information and the workplace

UINF0947.01 Operate Computing Tools in a network environment

UINF0948.01 Prepare text documents by using the advanced features of the computer application
UINF0949.01 Create spreadsheets using the advanced features of the computing application

Page 4
Location of the Subject or Module

Page 5
Training map
Disciplinary Field: Communication

Module I Module III Module IV


Application Systems development Design software
software
Module II
Hardware
and communications

Submodule
1Text file
management

48 hours

6 credits

Submodule

2Applied spreadsheets
64 hours
8 credits
Submodule
1Virtual communities

48 hours

6 credits

Submodule

2Maintenance and
computer networks64
hours
8 credits

Page 6
Symbolism

Icon Description
Reading: In this section you will find a reading in accordance with the study plan that
provides the necessary knowledge to complete the scheduled activities.

Audio-visual material: made up of both QR and URL links to facilitate access to relevant
information that complements an activity

Practice plan A: guided practices that help in the application of the knowledge
obtained, accompanied by the corresponding evaluation instrument.

Plan B Activity: Optional activities for schools that are unable to carry out a practice,
taking up the necessary elements of each reading.

Teacher explains: It is suggested that in this section the teacher deepens their
knowledge to adapt it to their context.
“Education that generates change”

PROGRAMMATIC DOSING
Submodule 1 CPBTIC5 Systems Development
CPBTIC6 Submodule 2 Programming
Sem: 5th. Period: 2021B (64 HRS)
Moment Time
Block Knowledge Week Start date Observations
(minutes)
1
Module Framework
Activity Build-T
2 240 Diagnostic Assessment 8 Oct 11-15
Programming logic,
3 Algorithms, Flowchart,
Pseudocode
240 Decisions, Cycles 9 Oct 18-22
SUBMODULE II: PROGRAMMING

Programming languages
420 Types of languages, 10 Oct 25-29
Programming
methodology Structured
Object-oriented
Programming using a
4 high-level language. November 1st and 2nd
420 Development 11 03-05 Nov. Official suspension of
environment variables, work
operators Constants
420 Reserved words
12 08-12 Nov.
Decision sentence
420 Structures 13 Nov 16-19
420 Condition, Repetition 14 Nov 22-26
420
Arrangements 15 Nov 29-Dec 3
5 420 Teaching situation 16 07-10 Dec.
6 420 Feedback 17 Dec 13-17

Totals 3,840
Evaluation criteria

Activities (Tasks, inputs, etc.) 30%

Practices or Evaluation 30%

Build-T Lesson 10%

Teaching situation 30%

Total 100%
Module IIISystems
Development

Submodule 2. Programming

HTML5

Python
Ard
uin
o

Information Systems .. ..
Page 11
Module III Systems Development

Submodule 1 Information Systems

Purpose of the Module


Proposes critical and responsible solutions through software development methodology to
demonstrate efficiency in database management and high-level programming software, which are
applicable to the needs of a company or institution for information processing.

Expected Learning Outcomes


• Uses the methodology for software development, promoting collaborative and creative work
in solving problems in its context.
• Uses different database models, showing willingness to work methodically and organized, to
solve problems in their context.

Competencies
Generic Professionals
• CG5.2 Sorts information from
according to categories, hierarchies
and relationships.
• CG5.6 Uses information technology • CPBTIC5 Proposes the design of
technologies information systems, based on the
information and communication to analysis of user needs, allowing for
process and interpret information responsible and innovative problem
• CG8.1 Proposes ways to solving in different contexts.
solve a problem or develop a team
project, defining a course of action
with specific steps

Information Systems
Page 12
“Education that generates change”

Teaching Situation

Qualification: Programming your senses

Context: In daily life, students use technology indiscriminately and do not make good use
of it. Accordingly, it is sought that they generate technological environments
integrating various areas of knowledge in order to acquire general and specific
programming skills in a responsible, analytical and critical way, allowing them to
address everyday problems and develop programs that benefit the institution and
the context, integrating them into a portfolio of evidence.

Cognitive Cognitive conflict. Do you know what programming software is?

conflict Can programming software create awareness in people?


What is structured programming?
What is a control structure and which ones did you apply to solve problems using
programs in Python 3?
What is nested condition and loop for solving problems programmatically in
Python 3?
What recommendations would you give for acquiring good habits and skills in
Python 3?

Information Systems
Page 13
Diagnostic evaluation.

Submodule II. Programming.

Name. Cluster.

No. of successes Qualification.

INSTRUCTIONS. Underline the answer you consider correct to each question.

1. Mention what is the process by which the software is designed, coded, cleaned and protected?
source code of computer programs?
a) Database
b) Programming
c) Software
d) Block diagram

2. Choose. What iscreate software, which will then be executed directly by the
computer hardware, or through another program?
a) Objective of programming
b) Advantage of programming
c) Disadvantage of programming
d) Programming risks

3. Choose. What is an algorithm?


a) It is a sequence of instructions that represent a solution model for
certain types of problems.
b) It is the graphic representation.

Page 14

Information Systems
It is written in normal language
d) It is the representation oftables

4. Select. What is it when no numerical calculations


COare performed
BATA B in your steps or instructions?
TABASCO HIGH SCHOOL
TABASCO
a) Algorithm 'Education that generates
change'

c) b) Qualitative algorithm
c) Quantitative algorithm
d) Pseudocode

5. Choose. What is the graphical representation of an algorithm?


a) Pseudocode
b) Natural language
c) Flowchart
d) Nassi-Sheneiderman diagram

6. Choose. What is the environment used to structure, plan and control the process of
systems development?
a) Methodology for software development
b) Definition of needs
c) Analysis
d) Design

7. Choose. What is the stage where the requirements for the development of the
software?
a) Methodology for software development
b) Definition of needs
c) Analysis
d) Design

Information Systems
Page 15
CO BATA B
TABASCO HIGH SCHOOL
TABASCO
'Education that generates
change'

8. Choose. What is the stage where it is essential that, through a collection of


functional and non-functional requirements, the developer(s) fully understand the nature of the
programs that must be built to develop the application, the required function, behavior, performance,
and interconnection?
a) Analysis
b) Design
c) Definition of needs
d) Methodology for hesoftware development

9. Choose. What is a sequence of instructions that represent a solution model?


for a certain type of problems?
a) Flowchart
b) Block diagram
c) Nassi-Sheneiderman diagram
d) Pseudocode

10. Choose. It is the set of tools that allow the programmer to develop computer programs, using
different alternatives in a practical way.
a) Programming language
b) Algorithm
c) Programming software
d) Programming logic

11. Choose. It is a fundamental key to being a good developer and programmer.


a) Programming logic
b) Programming software
c) Algorithm

Information Systems
Page 16
CO BATA B
TABASCO HIGH SCHOOL
TABASCO
'Education that generates
change'

d) Programming language

12. Select. It is a structured communication system that allows us to communicate, either through
words, signs, sounds or gestures with a computer.
a) Programming logic
b) Programming language
c) Programming software
d) Pseudocode

13. Choose. It is the process by which source code is written, tested, debugged, compiled (if
necessary) and maintained.
a) Programming
b) Pseudocode
c) Structured programming
d) Object Oriented Programming

14. Select. It is a paradigm ofprogramming based on using functions or subroutines, and


only three control structures.
a) Programming
b) Pseudocode
c) Structured programming
d) Oriented programming toobjects

15. Choose. It is a programming paradigm that uses objects in their interactions to design computer
applications and programs. It is based on several techniques, including inheritance, cohesion,
abstraction, polymorphism, coupling and encapsulation.
a) Object-oriented programming.
b) Programming

Information Systems
Page 17
Structured programming
d) Pseudocode

16. Select. In programming, they allow the execution


CO flow
BATAofBa program's instructions to be
TABASCO HIGH SCHOOL

modified. TABASCO
'Education that generates
change'
a)
c)
Structure sequential
b) Control structures
c) Structure selective
d) Structurecyclical

17. Choose. It is the simplest, being a series of actions to be executed consecutively.


a) Control structures
b) Structure selective
c) Structurecyclical
d) Structure sequential

18. Choose. Evaluates a logical expression, if it is true it executes one or more actions, if not true it
executes nothing.
a) Structure selective
b) Structure sequential
c) Control structures
d) Structurecyclical

19. Select. They allow the execution of an action or a group of actions to be repeated a determined
or indeterminate number of times.
a) Selective structure
b) Cyclic structure

Information Systems
Page 18
c) Sequential structure
d) Control structure

20. Choose. They increase the flexibility of the function by expanding the number of possible results
to test.
a) Nested cycle
b) Conditionmultiple
c) Condition nested
d) Condition simple.

Page 19

Information Systems
Reading 1 Programming logic.

Instructions: Perform the analysis of the following reading, marking the

main ideas and concepts.

What is programming logic?

Pelhon (2019) states that “programming logic is the coherent organization of the program instructions
so that its objective is achieved”, for which he recommends that the information be clear and organized
so that it contributes to the objectives that are desired to be achieved. On the other hand, anyone who
intends to build a program that provides a solution to a certain problem faces two major tasks:
• The WHAT: actions to be taken to resolve the problem. This task is part of the desk work prior to
any programming activity.
• The HOW: instructions that will be used to write the code that performs the actions determined in
the WHAT, which are determined by the programming language
selected.
Many people confuse Programming with Programming Logic, the first involves the knowledge of
techniques and instructions of a certain Language through which it is easy to get the Computer to
obtain results much faster than a person. The
second involves, in a technical and organized
way, the concepts that allow

Page 20

Information Systems
design, in general terms, the solution to problems that can be implemented through a computer.
(Ecured, 2021)

Logic is the basis of all programming knowledge, since it is possible to learn to write code so that the
computer can interpret it correctly. That is, you learn to communicate with the machine through a
language.

Programming logic is the organization and planning of coherent instructions in an algorithm, with the
aim of making the implementation of a program or software visible.

1.1.-Algorithm.

For Harry Guinness (2017), an algorithm is a In high level language Mtiirall


prescribed set of well-defined, ordered and finite
1. is the battery plugged in correctly?
instructions or rules that allows an activity to be 2. If the answer is NO we plug it in and the algorithm ends (optionally it can be

executed again)
carried out through successive steps that do not 3. If the answer is YES then is the bulb burned out?

4. If the answer is YES then we replace the focus and the algorithm ends.
generate doubts for the person who must carry out (can optionally be run again)

said activity. In a scenario with an initial state and an 5. If the answer is NO then it means that the lamp is damaged and we
proceed to buy a new lamp.

input, following successive steps a final state is


reached and a solution is obtained.

Algorithms can have the following characteristics:

Precise: and indicate the order in which each step is carried out.

Finite: If an algorithm is followed it must end at some point.

Defined: If you follow an algorithm twice, you must get the same result each time.

Page 21

Information Systems
There are algorithms, Quantitative (numerical calculations are used to define the steps of the process)
and Qualitative (steps in a Narrated form.)

Figure taken from Ferreyra, G. (2011). Computer Science Step by Step. Alfaomega Publishing Group.
Mexico. Pp. 26-29

The way of representing the Algorithms is


Ways to Express
precisely depending on the way in which it
an Algorithm
is desired to be observed:

a) Natural Language: A natural language


algorithm allows observing a
procedure from the following
stages: Start, process and
output of information in a simple manner.

b) Flowcharts: According to information technology (2021). The flow chart

Page 22

Information Systems
COBATAB
TABASCO HIGH SCHOOL
TABASCO
“Education that generates
change”
represents the algorithm through a diagram using various graphic symbols, called "blocks", in which
the actions that the algorithm must execute are described, connected to each other by lines
indicating the order in which the instructions must be carried out.

Various geometric figures such as rhombuses, squares or circles are often used to create a flow
chart.
Flowcharts help to solve and structure a problem.

c) Pseudocode: Pseudocode is a relatively simple way of expressing the


different steps that a program must take to achieve its objective

Do you want to learn more algorithms?

click on the following link:


https://www.youtube.com/watch?v=kUZy9PVD0EI

Page 23

Information Systems
1.2. -Flow chart.

Flowcharts are based on symbols that allow us to say the same thing as in algorithms, but in a graphical

way and, of course, a little more understandable. The following are some of the symbols (and their
meaning) that have been agreed to be used within Flowcharts
or Flowcharts: (Ecured.2021)

These symbols are connected to each other through arrows


and lines that mark the direction of flow and establish the path
of the process.

Rules for creating diagrams

1. Flowcharts should be written from top to bottom,


and/or from left to right.

2. The symbols are joined by lines, which have an arrow at the tip indicating the
direction in which information flows processes, only horizontal or vertical flow lines should be used
(never diagonal).

3. Crossing of lines should be avoided, which would result in separating the flow of the diagram to
a
different site, could be done using the connectors. It should be noted that connectors will only be used
when strictly necessary.

4. There must be no unconnected flow lines.

5. All text written inside a symbol must be legible, precise, avoiding the use of

Information Systems
Page 24
many words.

6. All symbols can have more than one input line, except the final symbol.
7. Only decision symbols can and should have more than one output flow line.
Flowcharts are extremely relevant in different technical areas where it is necessary to establish a certain
sequence of steps in a comprehensible way.

Below is the symbology of the Flowcharts

Information Systems
Page 25
Examples of the application of the symbology of Flowcharts in Pseudocodes:

There are 3 ways to represent algorithms according to Flowcharts, which are presented below:
Flowcharts with sequential, selective and iterative control structure (Cycles and loops.)

Information Systems
Page 26
A flowchart can be made using different computer tools that make the issue extremely easy, such as
Power Point, SmartDraw, and Lucidchart. Etc.

1.3. Pseudocode.

It is a technique used to write computer programs in natural language in such a way that it facilitates
if lamp plugged in correctly = false then
understanding, testing and subsequent coding in a plug in lamp
end (can optionally be run again) else focus is burned
specific programming language (Gómez, 2021). = true
replace light bulb
end (optionally can be run again) buy new lamp

For example:

Algorithm to request two numbers and display the sum of both

START

WRITE("Enter two numbers to add:");

READ (Number 1, Number 2);

Result <- Numeral + Number2;

WRITE("The sum is:", Result);

END

According to Information Technology (2021), when writing pseudocode, users have three basic types of
control structures available: sequential, selective, and iterative.

Page 27

Information Systems
Sequential structures: Instructions are followed in a fixed sequence that is usually defined by the row
number. This means that instructions are executed from top to bottom.

Example: Sum of 2 numbers represented by A AND B

1. Start
2. Read A, B
3. Make S = A + B
4. Write S
5. End

Selective structures: Selective instructions represent instructions that may or may not be executed,
depending on the fulfillment of a condition.

There are other selective structures such as:

• Structure simple decision


• Structure double decision
• Structure multiple decision:

Page 28

Example: ALGORITHM ENTER TWO NUMBERS AND INDICATES WHICH IS GREATER.

1. START
2. WRITE("Enter two numbers");

Information Systems
3. READ( x, z );
4. IF( x > z )
5. WRITE("True");
6. END YES
7. END

Iterative structures (Loops): The iterative or repetition structure allows one or more instructions to be
executed a certain number of times or indefinitely as long as a certain condition is met.

Within this structure, it is common to find COUNTERS (Variable used to count the cycles of the Loops)

There are other iterative structures such as:

• While
• Repeat
• For
• Do
Example: Algorithm that asks for a number and writes its square (Repeat)

1. START
2. Counter <- 0;
3. REPEAT
4. Counter <- Counter + 1;
5. WRITE("Current number: ", Counter);
6. UP TO(Counter == 100 )
7. END

Page 29

CO BATA B
TABASCO HIGH SCHOOL
TABASCO
'Education that generates
change'
There are several advantages to using a Pseudocode for a Flowchart, to mention a few:

• It takes up less space on a sheet of paper.


• It allows to easily represent complex repetitive operations.
• It is very easy to go from pseudocode to a program in any programming language.
• If the rules are followed, you can clearly see the levels of each operation.

Information Systems
Page 30

Information Systems
Instructions: After having analyzed the reading about programming
logic, complete the sun diagram.

Page 31

Information Systems
CO BATA B
TABASCO HIGH SCHOOL
TABASCO
'Education that generates
change'
References

Ferreyra, G. (2011). Computer Science Step by Step. Alfaomega Publishing Group. Mexico. Pp. 26-
29

Gomez, L. A., (2021), Algorithms, Autonomous University of the State of Hidalgo, retrieved from:
https://www.uaeh.edu.mx/scige/boletin/prepa4/n10/e1.html.

Marker Graciela().Pseudocode: What is it? How to make one? Examples

Monica E. García(2021).Algorithms and pseudocodes.UTM. Recovered from


https://www.utm.mx/~mgarcia/DA3(Definiciones).pdf

Programmer X (12 Mar 2021). Programming Logic Learn to program in 10


minutes.[Video].YouTube. Retrieved from https://www.youtube.com/watch?v=as1opL254NA

Technology Computing. Recovered of https://www.tecnologia-


informatica.com/pseudocodigo/#Seudocodigos_y_diagramas_de_flow

Page 32

Information Systems
Instructions: Study the following reading carefully and do the activity My
First Algorithm
2.1. - Decisions.

Decision statements, also called flow control statements, are control structures that ask a question
which returns true or false, evaluate a condition and select the next instruction to execute
depending on the answer or result.

The decisions are represented in the pseudocodes, through a control structure with logical
expression that involves the use of the following symbols:

LOGICAL EXPRESSION WAY TO REPRESENT THEM IN THE


FLOWCHART

If logical expression Then

Action

FinSi

According to the control structures studied, decisions can be classified as follows:

Page 33

Information Systems
Simple decision structure:

This is the simplest type of conditional structure. Executes a statement or block of


statements when the statement (condition) is true (IF); if it is false, does nothing.
This decision-making takes place as follows:

If logical expression > Then

Action

EndYes

Double decision structure:

This type of structure allows you to implement conditionals in which there are two
alternative actions:

• If the proposition (condition) is true, a series of instructions will be executed


(block 1).
• If it is false (Else), another series of instructions is executed (block 2).

Yeah<condición> So
Action(s)
But
Action(s)
FinSi

Page 34

Information Systems
Multiple decision structure:

It allows to implement more complicated conditionals, in which conditions are


“chained” in the following way:

• If condition 1 is true, execute the instructions in block 1.


• If condition 1 is not met, but condition 2 IS met, execute the instructions in
block 2.

• If not, that is, if none of the previous conditions have been verified, execute the
instructions in block 3.

Yeah<condición> So

Action(s)

But

Yeah<condición> So

Action(s)

But

Various conditions

The application of decisions and cycles or loops in Algorithms allows solving problems by applying
programming logic with a minimum of steps, offering precise and well-defined results.

Page 35

Information Systems
2.2. - Cycles or loops.

A loop or cycle in programming is a sequence that


repeatedly executes a piece of code until the condition
assigned to said loop is no longer met. The three
most commonly used loops in programming are the while
loop, the for loop, and the do-while loop.

An iterative cycle is the repetition of


operations until a condition is met. The
operations or instructions are the same but the data
being processed may change during the execution
of the cycle. (UACJ, 2021)

In order to work with these structures, it is necessary to first understand the special loop variables:
Counters and Accumulators.

Page 36

Information Systems
COBATAB
TABASCO TABASCO HIGH SCHOOL

-IIAI I“ dycaciór.quege ñero combio"


Example of the application of Loops in algorithms

Exercise: Design a program that writes numbers up to 5

Pseudocode Flowchart Interpretation of the lines

START
START
Integer i LET'S COUNT TO 5
Write "Let's count to 5" -
i=0 II We initialize ia to zero so that in the first comparison it has that value
While (i <= 5)
, 1>5
.-------> FROM i=0 TO 5 -------, // It will repeat the two loop instructions as long as i <= 5 is true
Write i
i=i+1
II In this line the value of i is increased by 1, otherwise it would always be 0.
Write "End"
END

,-
---------------- 1=1+1

Result: 1,2,3,4,5,

TIN"

We can observe the minimum of the written code and the actions it performs in the Flowchart

Information Systems
Page 37
Within the cycles or loops we find the following structures:

➢ Iterative structure While

STRUCTURE
REPRESENTATION OF
REPETITIVE OR DESCRIPTION EXAMPLE
ALGORITHMS
LOOP

WHILE The instructions are Flow chart that


(WHILE) repeat P False
visualize the numbers
< Condition >---------------------------
continuously from 1 to 10
as long as the Start
TRUE
condition is met. You l"J
it may
will be happen
able to that Instructions

< i.e. 10 B-
the cycle is never
v
executed
If the condition is not CD \
II
met

— C'

Information Systems
Page 38
CO BATA B
TABASCO TABASCO HIGH SCHOOL

“Education that generates


change”
➢ Iterative Structure For (FOR)

STRUCTURE DESCRIPTION REPRESENTATION OF EXAMPLE


REPETITIVE OR ALGORITHMS
LOOP

Cycle FOR HE presents Flow chart that


(FOR ) through a Initialization
visualize the numbers
Condition
-• Change
rectangle. * In from 1 to 10
the first — Start
section is put Instructions
p “Enter a X k" number" /
initialization.
//
* In the part End of the cycle
---------—------------ ie=10 F

longer is
—• i=i+1

puts the
condition. * In n, ** * ",l, ” ° ",
n*l )
the third part (End
the change.

Page 39

Information Systems
➢ Iterative Structure Repeat

STRUCTURE DESCRIPTION REPRESENTATION OF EXAMPLE


TO ALGORITHMS
REPETITIVE
OR LOOP

REPEAT Repeatedly and Initialize index variable

unconditionally -------OR
actions

executes a set of
Operations)
l
instructions Increment variable

TRUE ,, .. S1 index variable


------ < (Condition) > final value —

I False
No

The condition will be a logical proposition, that is, an expression that will either be true or false. If
the condition is true, the set of instructions is executed. When the set of instructions has finished
executing, the flow is directed back to the condition, forming a loop, cycle, or iteration. When the
condition is false, the flow continues to the next statement (branch to the right of the condition
(iterating, 2021).

In general, loops must terminate after a certain (finite) number of repetitions, and the set of
operations to be repeated is known as a loop. (UACJ, 2021)

Page 40

Information Systems
Do you want to learn iterative structures?

Click on the following link or QR code

https://www.youtube.com/watch?v=E8f1rwUfNG4

Do you want to know more about programming logic?

Click on the following link, or QR code

https://www.youtube.com/watch?v=as1opL254NA

Information Systems
Page 41

Information Systems
Activity 2: My first algorithm

Instructions: Make your first Iterative algorithm (Loop), which adds the
first 15 natural numbers.

Description of the iterative


Pseudocode Flowchart
structure used.

111
References

Information Systems
Page 42
Ecured (2021), Logic of the programming, recovered of
https://www.ecured.cu/L%C3%B3gica_de_programaci%C3%B3n

Guinness, H. (2017). How Facebook's news feed sorting algorithm works. Retrieved from:
https://www.howtogeek.com/290919/how-facebooks-news-feedsorting-algorithm-works/

Esquivel K. (2015). Algorithms. Unit III – Logical Decision Structures. Department of


Computing. UNAN-Leon. Website:
https://kesquivel.files.wordpress.com/2015/07/estructuradecisionlogicaiii_2015.pdf

Oviedo E. (2015). Programming logic. Chapter 4. Logical Decision Structure. Website:


http://uneweb.com/tutoriales/Diplomado%20Programacion%20Web/LOGICA/Logica- of-
Programming-Efrain-Oviedo.pdf

Department of Differential Equations and Numerical Analysis. Programming algorithms and structures. (March 2,
2009). University of Seville. Website: http://departamento.us.es/edan/php/asig/LICFIS/LFIPC/Tema5FISPC0809.pd
HE PROCESS OF THE PROGRAMMING
http://www3.uacj.mx/CGTI/CDTE/JPM/Documents/IIT/repetitivas/iterativos.html

Interactive algorithmic structure http://iterando.online/estructura-algoritmica/iterativa/

Exercises loops
https://www.edu.xunta.gal/espazoAbalar/sites/espazoAbalar/files/datos/1554983496/contido/Ro
boticaEnElAula/ejercicios_bucles.html

Exercises of algorithms
http://centros.edu.xunta.es/ieseduardopondal/tecnoweb/temas_informatica/2bac/ejerc_algorit.p df

Henao C.(2021). ¸Iterative Structures or Cycles S Examples Algorithmsv .[Video].YouTube.


https://www.youtube.com/watch?v=E8f1rwUfNG4

Information Systems
Page 43
Reading 3: “Programming Languages”

Instructions: Read the following, mark the main ideas and complete the
the suggested activity or the one indicated by your teacher.

Over the years, programming languages have evolved in the development of systems or software,
for this reason, as a programmer it is
important to know the basic concepts of
programming, the types of languages
used for their development and
operation, to interpret algorithms and to
solve problems through programs.

A programming language is a software


tool that allows us to develop software or computer programs.

Programming languages are used to design and implement programs responsible for defining and

manage the behavior of a computer's physical and logical devices.

Broadly speaking, a programming language is made up of a series of symbols and rules of syntax
and semantics that define the main structure of the language and give meaning to its elements and
expressions.

Programming is the process of analysis, design, implementation, testing and debugging of an


algorithm, from a language that compiles and generates a source code executed in the

Information Systems
Page 44

computer. The main function of programming languages is to write programs that allow user-
machine communication. Special programs (compilers or interpreters) convert instructions written
in source code into instructions written in machine language (0 and 1).

Interpreters read the instruction line by line and obtain the corresponding machine code. As for
compilers, they translate the symbols of a programming language into their equivalent written in
machine language (a process known as compiling). Finally, an executable program is obtained.

Phases of compilation
Compilation allows the creation of a computer program that can be executed by the computer and
involves three steps:

Page 45

Information Systems
Some compilation processes may have variations, but in
general it looks like this:

But what is the difference between a compiler and an


interpreter? Compilers perform translation at development time,
that is, the program is not yet running. The compiler
receives all the source code, analyzes it, optimizes it and
translates it into machine language, leaving a complete
program ready for execution. For example, C or Pascal are
compiled languages.

Interpreters, on the other hand, perform translation at


runtime, that is, as the program is running, the interpreter
translates instructions into machine language. Basic is an
interpreted language.

3.1. - Classification of types of languages


✓ Machine language. It is the system of codes (0s and 1s) that can be directly interpreted by a
microprogrammable circuit such as a computer's microprocessor.
✓ Low-level or first-generation language. It is one in which its instructions exercise direct control
over the hardware and are conditioned by the physical structure of the computers that support
it.
✓ High-level language. They are characterized because their semantic structure is very
similar to the way humans write, which allows algorithms to be encoded in a more
natural way.

Information Systems
Page 46
• Number sequences (0'5 and 1'5)
• Language specific to each computer

• Uses codes similar to English


• Varies according to the type of
processor
- Example: LOAD X ADD Y STORE Z

• Irsurucciorcs in a Partíillar language


• Uses familiar mathematical notations
Example: Z = X+Y
• Machine independent

Some programming languages

✓ Fortran. It was developed in the 1950s and has been actively used ever since (acronym for
Formula Translation).
✓ C++. (High level language). It was designed in the mid-1980s by Bjarne
Stroustrup covers two programming paradigms: structured and object-oriented.
✓ Java. Object-oriented programming language developed by Sun Microsystems in the early
1990s.
✓ PHP. It is frequently used to create content for websites with which HTML pages and
source codes can be programmed. PHP is an acronym that stands for hypertext
preprocessor.
✓ Python. It is a modern programming language, licensed under a free software license; it is
object-oriented, but also supports procedural and functional programming styles.

Page 47

Information Systems
Components of programming languages

Data types and structures

Data structures are elements of programming languagesthat allow

more efficiently manipulate diverse variables: numeric or text type (character strings), and other
more complex ones, as
vectors, matrices, pointers, etc.

Instructions
They are predefined grammatical
structures, very similar to human
language, to generate sequences of
actions that make up a program.
They range from basic arithmetic
and logical operators (addition,
subtraction, and, or) to more
specialized instructions to perform various actions within the program, such as saving files,
dumping text to the screen, etc.

9print (“Hello World!!!”)


# Write Hello World!!!

> input ("Tell me your name ")


# Type "Tell me your name" and wait for a string to be entered.

>>type0 # To know the type of a data or variable

>>> int () # To change the type of a data to integer

» float () # To change the type of a data to real

»str () # To change the type of a data to string

Information Systems
Page 48
Flow control

It refers to the sequence of actions of a program. Sometimes, within the sequence of instructions,
there are points where the program must make decisions based on the value of a variable or the
fulfillment of a certain condition. The type of instructions that enable these actions are, precisely,
those of flow control: conditional (if-then-else), loop (for or while) or selection (case).

n = input( enter number: ) is entered n


i=& # We start from 0
r = [] # result
while i <- 19: we iterate up to 19
m = n*i # ■ is multiples of n
r = r + [i] # is added to the result
1 = 14-1 4 new iteration
print r # when i = 20 we show the result

Page 49

Information Systems
Activity 3. Word Search “Programming Languages”

Instructions. Taking into account the concepts learned in reading 1, answer the following
questions and look for their answers in the following Soup

Take a photo of the activity as evidence of your solution.

Questions to answer the word search.


1. Code system directly interpretable by a microprogrammable circuit
which consists of a set of instructions that determine actions that will
be performed by the machines. Machine language
2. receives all the source code, analyzes it, optimizes it and translates it into machine
language
leaving a complete program ready for execution. Compiler
3. It is the process of analysis, design, implementation, testing and debugging of an algorithm,
from a language that compiles and generates source code executed on the computer.
Programming
4. In which its instructions exercise direct control over the hardware and are
conditioned by the physical structure of the computers that support it. Use codes
similar to English. Low level language
5. It performs the translation at runtime, that is, as the program is executed, the interpreter
translates instructions into machine language. Interpreter
6. It is a modern programming language, it is under a free software license; it is
object-oriented, but also supports procedural and
functional. Python
7. They are predefined grammatical structures, very similar to language
human, to generate sequences of actions that make up a program.

Information Systems
Page 50

Information Systems
Instructions
8. Object-oriented programming language developed by Sun Microsystems in the early 1990s.
Java

L N V S XAN TO V C TO J
NX P S
D
TO AN T EIT M
C P Y L TO D EIT R AN AN
D HE o HER D D
M AN N AN
OR R TO N TO L Yo T T M N
DY D
D S Ñ EIT
G G D C C TO AN EIT TO EIT
o HE AN TO TO N D HER HER
V TO L D OR T R M YoN Yo
D
TO M N Ñ AN TO P C AN P S EIT C AN C
YM J D D HER D
L D F J W R T Yo S C H C
o
P AN T H EIT N G AN TO R EIT T OR F OR
D HE D HE AN
D F Yo M Yo K T N M S D R G R
D
*TO G OR D N N P OR N TO VOR T OR T
C K EIT Yo Yo V S Yo B H QP SL S
HER
AN N AN
Yo C OR S TO B
L OR N P J N
D
EIT G D
P R R TO M TO C Yo EIT N YoK Yo
HER AN HE
N C P L V R TO OR H J K MN S
EIT D AN D L EIT R T
J OR L F N EIT C TO
HER D HE HER

Page 51

CO BATA B
TABASCO HIGH SCHOOL
TABASCO
'Education that generates
change'

Information Systems
References

CUAED (2017). “Programming Languages. Learning Support Unit.


https://programas.cuaed.unam.mx/repositorio/moodle/pluginfile.php/1023/mod_resource/
content/1/contenido/index.html

Page 52

Information Systems
Reading 4. Structured Programming Methodology

Instructions: Read the following, identifying the main concepts and use them to
create the Concept Map activity at the end.
4.1. - Structured programming

Structured programming is a programming paradigm based on using functions or


subroutines, and only three control structures:
• sequence: execution of one statement after another.
• selection or conditional: execution of a statement or set of statements, depending on the value of a
boolean variable.
• iteration (cycle or loop): execution of a statement or set of statements, while a boolean variable is true.

This paradigm is based on the corresponding theorem, which establishes that every computable function can be
implemented in a programming language that combines only these three logical or control structures.

Control structures:
1. The sequential structure is the one that occurs naturally in the language, since by default the
Statements are executed in the order in which they appear written in the program.
Python example

•K

Information Systems
Page 53
2. For conditional or selection structures, Python has the if statement, which
can be combined with -elif and/or else statements. There is a YES or NO decision in its
lines.
Python example
Select! goes. py X
i «Program that asks for age and says whether the person is of legal age or a minor.
2
3 age = int(input(“Tell me your age:”))
4 if age>=18:
s print("You are of legal age")
6else:
7 print("You are a minor")
s print("Program finished")
9 # Write your code here :-)
10

3. For loops or iterations there are the while and for structures. The lines of code will be
repetitive until the condition is met.
Python example
Acids.py X
i # program that asks the user for a password, repeatedly as long as he does not enter “Tics”
2 # When you finally enter the correct password, you will be told “Welcome” and the program will end
3 secret = “Tics”
4 key = input("Tell me the key:")
5 while key != secret:
and print("Incorrect key!!!")
7 key = input("Tell me the key:")
8 pri nt("Welcome!!!")
9 print("Program finished")

Functions:
Structured programming seeks to divide or decompose a complex problem into smaller problems.
The solution to each of these small problems brings us the solution to the complex problem. In
Python, the formulation of these small solutions to the complex problem is done by dividing the
program into functions.

A function is a set of instructions in Python that solve a specific problem. The use of functions is a
very important component of the so-called structured programming paradigm, and has several
advantages:

Page 54

Information Systems
✓ Modularization: allows a complex program to be segmented into a series of simpler parts or
modules, thus facilitating programming and debugging.
✓ Reuse: allows the same function to be reused in different programs.

Example of a function in Python.


fundon, py X

i function that displays the greeting Hello friend! on the screen Every time she is invoked
2 def greeting():
3 Function that displays the greeting Hello friend! on screen.....................................................
4 print('Hello friend!')
s return
6

7 greeting ()
Executing: function.Dv

[Hi friend!

4.2.- Object Oriented Programming Methodology

Object Oriented Programming (OOP) is a model or


programming style that gives us guidelines on how to work
with it. It is based on the concept of classes and objects.

Over the years, different programming paradigms or models


have emerged. Sequential languages like COBOL or procedural
languages like Basic or C focused more on logic than data.
Other more modern ones such as Java, C# and Python, use
paradigms to define programs, with Object Oriented Programming being the most popular.

The Object Oriented Programming paradigm seeks to focus on the pure logic of programs, to begin
to think about objects, which constitutes the basis of this paradigm. This is vital for the
development of large systems, since, instead of thinking

Information Systems
Page 55
In functions, we think about the relationships or interactions of the different components of the
system.

A programmer designs a software program by organizing related pieces of information and


behaviors into a template called a class. Individual objects are then created from the class
template.

Classes, Objects and Instances

A class is a template. It defines in a generic way what objects of a certain type will be like. For
example, a class to represent animals can be called 'animal' and have a series of attributes, such as
'name' or 'age' (which are usually properties), and a series of behaviors that they can have, such as
walking or eating, and which in turn are implemented as methods of the class (functions).

A simple example of an object, as we said before, could be an animal. An animal has an age, so we
create a new attribute 'age', and it can age, so we define a new method. Data and logic. This is
what is defined in many programs as the definition of a class, which is the global and generic
definition of many objects. With the class you can create instances of an object, each of them with
its attributes defined independently. With this we could create a cat called Paco, 3 years old, and
another animal, this one a dog and called Pancho, 4 years old. Both are defined by class
animal, but they are
ANIMAL
two different
instances. Therefore,
calling its methods can
have results CLASSES

different. They both


share the same logic, DOG OBJECTS
but each has its own
independent state.

Information Systems
Page 56
4 principles of Object Oriented Programming

1 .- Encapsulation

Encapsulation contains all the important information of an object within the object and only
exposes selected information to the outside world.

2 .- Abstraction

Abstraction is when the user interacts only with


selected attributes and methods of an object, using
simplified high-level tools to access a complex
object.

3 .- The inheritance

Inheritance defines hierarchical relationships


between classes, so that common attributes and
methods can be reused. Parent classes extend
attributes and behaviors to child classes.

4 .- Polymorphism

Polymorphism is about designing objects to share behaviors, allowing us to process objects in


different ways. It is the ability to present the same interface to different underlying forms or data
types.

Information Systems
Page 57
Benefits of Object Oriented Programming

✓ Code reuse.

✓ Turn complex things into simple, reproducible structures.


✓ Avoid code duplication.

✓ It allows teamwork thanks to encapsulation, as it minimizes the possibility of duplicating


functions when several people work on the same object at the same time.
✓ Because the class is well structured, it allows for error correction in various places in the code.
✓ It protects information through encapsulation, since the object's data can only be accessed
through private properties and methods.
✓ Abstraction allows us to build more complex systems in a simpler and more organized way.

Page 58

Information Systems
Activity 4: Conceptual map of “Programming Methodologies

Instructions: Individually, make a conceptual map, according to the previous reading. You
can include images in your map. You can use digital tools to create your map (GoConqr,
canva,
midmaster, etc.).

Page 59

Information Systems
Assessment Instrument CHECKLIST
Activity 4 “Conceptual map,” Programming methodology”

GENERAL DATA
Name(s) of student(s) Registration number(s):
Product: Conceptual map Date:
Subject: Period:
Name of teacher: Teacher's signature:

REAGENT VALUE OBSERVATIONS AND/OR


VALUE CHARACTERISTICS TO BE COMPLIED OBTAINED CALIF SUGGESTIONS FOR
WITH IMPROVEMENT
YEAH NO
1 The map contains the name of the topic.

1 The creation of the map is based on a


central concept.
2 Hierarchize the ideas primaries
and
1 secondary, as the case
Presents concepts, maywords
linking be. and/or
propositions.
1 The relationship between concepts is
established.
1 The concepts are in
boxes/clouds/ovals.
1 Synthesize properly he issue
proposed.
1 The activity has a visual impact and does
not present spelling errors.
1 Delivered on time and in the correct
manner.
QUALIFICATION

Information Systems
Page 60

CO BATA B
TABASCO HIGH SCHOOL
TABASCO
'Education that generates
change'
Reference

CONVANTEC (2014). “Functions and structured programming”. https://python-training-


basics.readthedocs.io/en/latest/lesson5/index.html

Munoz J. D (2021). “Repetitive control structures: while”.


https://plataforma.josedomingo.org/pledin/cursos/programacion_python3/curso/u17/

Page 61

Information Systems
Reading 5. Programming using a high-level
language.

Instructions: Read the following text, underlining the ideas.


main.

Python is a very powerful and flexible general-purpose programming language, while being simple
and easy to learn. It is a high-level language that allows easy processing of all types of data
structures, both numeric and text.

This language was created by Guido Van Rossum, beginning its development in 1989 and starting to
be implemented in February 1991, when the first public version was published: 0.9.0. Version 1.0
was released in January 1994, version 2.0 was released in October 2000, and version 3.0 was
released in December 2008. Python is developed under an OSI-approved open source license, so it
can be freely used and distributed, even for commercial use. The Python license is managed by the
Python Software Foundation.

The features are summarized below:


• It is an interpreted language in which the programmer's code is translated by an interpreter as
necessary, not compiled.
• Uses dynamic typing, strongly typed which means the type of value does not change
suddenly.
• It is multiplatform, its source code can be run between several macOS systems,
Windows, Linux and Unix.
• It is a multi-paradigm programming language, which supports several programming paradigms.
programming such as object-oriented, structured, imperative programming and, to a lesser
extent, functional programming.

Page 62

Information Systems
• In Python, the format of code (p. e.g. indentation) is structural.

Python files have the extension .py. They are text files that are interpreted by the compiler. In
order to run programs in Python, you first need the Python interpreter, and secondly the code
you want to execute.

5.1 Development environments

Installing Python for Windows 10


1. Go to the Python URL at the following link: https://www.python.org/
2. Go to the downloads section and click on Python 3.9.0 to download the executable for
Windows (From there you can also download the Python version according to your
computer's operating system).
3. Once it is downloaded, click on it and the Python installation wizard on Windows 10 will
open and first activate the Add Python 3.9 to PATH box.

4. Then select the Customize installation option and you will see the screen like the following:
5. You can then enable or disable the optional Python features and click Next.

Page 63

Information Systems
6. In the next window you will see some additional options and you must activate the box
Install for all users and this will change the path where Python is installed on the system.

7. Then click on Install to carry out the installation process of Python 3.9 on Windows 10.
8. Once this process comes to an end we will see the following. We click on Close to
exit the wizard.

Installation of Mu
Mu is an open source editor that seeks to make it easier for students to learn to code with Python, it
is a creation of Nicholas Tollervey, it is an open source application (licensed under GNU GPLv3)
written in Python. It was originally developed to work with the Micro bit minicomputer. Feedback
and requests from other educators prompted its creator to rewrite Mu as a generic Python editor.

Page 64

Information Systems
CO BATA B
TABASCO HIGH SCHOOL
'Education that generates change'

If you are a Windows user, you can install Mu Editor with a .exe installer as follows:
1. Go to https://codewith.mu/en/download
2. Download the Windows installer that corresponds to your processor architecture.
3. Open it and accept the security notice.
4. Complete the steps in the installer and click install.
TABASCO

5.2. Variables
A variable is a place that stores certain information. Depending on the type of information we store
(text, numbers, boolean, etc.), the variable will be of one type or another, that is, they are defined
dynamically.

Three parts are involved in the variable assignment operation:

• The assignment operator =


• An identifier or variable name, to the left of the operator.
• A literal, an expression, a function call, or a combination of these to the right of the assignment
operator.

Each variable must have a name with which we can refer to it.

• Python takes into account whether we write the variable in upper or lower case (case
sensitive).
• Variable name cannot match python "command" names
(if, for, etc.).
Variable names cannot be used with tildes or ñ.

Page 65

Information Systems
Examples: # Assign to the variable<a2> # Assign to the variable<a3>
# Assign to the variable<a1> the result of the expression the character string
the value 1 3*4 'Pythonista'

a=1 a2 = 3 * 4 a3 = 'Pythonist'

To understand the following example we require the print() function.


The print() function is a function, so the content must always be in parentheses and is used to
display text or even the value of a variable.
>>>print('text')
text
Example editor Mu.

1 a=1
2 a2 =3*4
3 a3 = 'python sta'
4 print (a)
5 print (a2)
6 print (a3)
7 print("This is a text")
8

The input() function


Allows users to enter data of various types from standard input (usually keyboard input). When the
function is reached, the program pauses waiting for something to be typed and the Enter key to be
pressed. By default, the input() function converts the input to a string, even if we enter a number. If
we try to perform operations, an error will occur.
Example:

Page 66

Information Systems
If you want Python to interpret the input as an integer, you must use the int() function, to have
Python interpret the input as a decimal number, you must use the float() function. But if the user
does not enter a number, the int() or float() functions will throw an error.

Enter data of different types

age = int(input('Enter age: ')) # integer input weight = float(input('Enter weight: ')) #
float input name = input('Enter name: ') # string input print(name, age, 'years', weight,
'kg') # display data

Entering data with error (exceptions) capture

try: # block of code to check


articles = int(input('Articles:')) # input of a number
price = int(input('Price:')) # input of a number
print('Pay: ' + str(items*price) + '€') # show result

except: # block for error catching


print('error, must be numbers') # displays message

Comments
They are character strings which constitute an essential aid both for the person developing the
program and for other people who read the code.

Page 67

Information Systems
They can be added in two ways:

• By typing the number character # in front of the line of text where the comment is.
• By writing triple double quotes (""") at the beginning and end of the comment (which can take
up more than one line).

Example:
i # This is a one line Python comment
2 print( "Example of a one-line comment")

3 print) "Example of a Comment after a statement")

4 .......
#4 After a statement

5 This is a multi-line comment


, II II II b

7 print) "Multiline comment")

Numbers
Integers:
These are numbers that do not have decimals and can be positive and negative (0 is also an integer).
These numbers are known as int (integer) or long (long integer for more precision).
Examples: x = -4
y = 20

Float: can be positive or negative, containing one or more decimals.


Examples: x = 3.5502
z = -35-59
Complex: are those that have a real part and an imaginary part. The imaginary part is written with a
"j".

Information Systems
Examples: x = 3 + 6j
y = 5j

Page 68

Information Systems
Type of chains

Variables that store text are called strings (str). They must be between single (') or double («)
quotes, or if the text spans several lines, between triple double quotes («»»).

Example
> >> # We define two variables called text > >> # We define a new variable text3 that
and
> >> # includes multiline text.
> >> # text2, and we will associate a text to
each one > >> text3="""Hello

> >> text="This is a text" ... Students"""

> >> text2='This is another text' > >> print (text3)

> >> print (text) Hello

This is a text Students

> >> print (text2)

Types of booleans

This is the type of variable that can only have True or False. They are values widely used in
conditions and loops.
A boolean variable can be declared as follows.
x = True
y = False

Page 69

Information Systems
5.3 Operators
Operators are special symbols that represent calculations, such as addition or multiplication, and the
values to which these operators are applied are called operands.

Arithmetic operators
Suppose variable a = 10 and variable b = 20, then:

Operator Description Example


+ Addition Adds values to both sides of the operator. a + b = 30
– Remains Subtract the right-hand operand from the left-hand a – b = -10
operand.

* Multiplication Multiplies the values on either side of the operator a * b = 200


/ Division Divide the left-hand operand by the right-hand operand b/a = 2

% Module Divides the left operand by the right operand and returns b% a = 0
the remainder
** Exponent Performs exponential (power) calculations on operators a**b=10 to the
power 20
// Radix division: The division of the operands where the 9 // 2 = 4 and 9.0 //
result is the quotient in which the digits after the decimal 2.0 = 4.0, -11 // 3 = -
point are removed. But if one of the operands is negative, 4, -11.0 // 3 = -4.0
the result is zeroed, that is, it is rounded away from zero
(towards negative infinity) –

Page 70

Information Systems
Python Comparison Operators
These operators compare the values on either side of them and decide the relationship between
them. They are also called relational operators. Suppose variable a = 10 and variable b = 20, then:

Operator Description Example


== If the values of two operands are equal, then the condition (a == b) is not true.
becomes true.
!= If the values of two operands are not equal, then the (a != b) is true.
condition becomes true.
<> (a < > b) is true. This is
If the values of two operands are not equal, then the
similar to the operator!
condition becomes true.
=.
> If the value of the left operand is greater than the value of
(a > b) is not true.
the right operand, the condition becomes true.
< If the value of the left operand is less than the value of the (a < b) is true.
right operand, the condition becomes true.
>= If the value of the left operand is greater than or equal to (a >= b) is not true.
the value of the right operand, the condition becomes true.

<= If the value of the left operand is less than or equal to the
(a <= b) is true.
value of the right operand, the condition becomes true.

Python Logical Operators


Suppose variable a = 10 and variable b = 20, then:

Operator Description Example

Information Systems
Page 71
and Logic And If both operands are true, then the condition
(a and b) are true.
becomes true.
logical OR (a or b) is true.
If either operand is nonzero, the condition is met.

not logical NOT not (a and b) is false.


It is used to reverse the logical state of its operand.

5.4 Constants

A constant is a type of variable which cannot be changed, they are usually declared and assigned in a
module. Module means a new file containing variables, functions, etc; which is imported into the
main file. Within the module, constants are written in UPPERCASE letters and words are separated
with the underscore character _.

In Python, constants are written using capital letters separated by the _ symbol. Now, just like types,
some constants come built into the Python language. Below we specify each of them:

1. None: The type assigned with the constant none has a single value applicable to a single
object. Therefore, its value cannot be used in different situations.
2. NoteImplement: Like None, this constant has a single value and applies to a single object.
However, it has some rich numerical and comparison methods to indicate that it is not being
implemented relative to another type.

Information Systems
Page 72
CO BATA B
TABASCO HIGH SCHOOL

'Education that generates change'

3. Ellipsis: This constant also has a single value applicable to a single object. Its presence
indicates that there is a syntax, usually enclosed in quotation marks.
4. False: Like true, this constant is of boolean type. It can only have two values, and this one,
as the name indicates, represents a false condition.
5. True: A boolean value that represents that a conditional expression or loop is true.
TABASCO

6. _debug_: If Python was not started with


option 0, then this constant will default to true.

5.5 Reserved words

Below is a list of each of the reserved words.


1. False – Boolean value, result of comparison operations or logical operations in Python
2. None – Represents a null value
3. True – Boolean value, equal to false, result of comparison operations or logical operations in
Python
4. peg_parser – So-called easter egg, related to the release of the new PEG parser is not
defined yet.
5. And – Logical operator
6. As – Used to create an alias when importing a module.
7. Assert – Used for debugging purposes
8. Async – Provided by the 'asyncio' library in Python. It is used to write concurrent code in
Python
9. Await – Provided by the 'asyncio' library in Python. It is used to write concurrent code in
Python
10. Break – Used inside for and while loops to alter their behavior
normal

Page 73

Information Systems
CO BATA B
TABASCO HIGH SCHOOL
'Education that generates change'

11. Class – Used to define a new user-defined class


12. Continue – Used inside for and while loops to alter their normal behavior
TABASCO
13. Def – used to define a user-defined
function
14. Del – To delete an object
15. Elif – Used in conditional statements, same as 'else' and 'if'
16. Else – Used in conditional statements, same as 'elif' and 'if'
17. Except – Used to create exceptions, what to do when an exception occurs, same as 'raise'
and 'try'
18. Finally – Using it ensures that the code block inside it is executed even if there is an
unhandled exception
19. For – Used to make loops. We generally use it when we know the number of times we want
that loop to run.
20. From – To import specific parts of a module
21. Global – To declare a global variable.
22. If – Used in conditional statements, same as 'else' and 'elif'
23. Import – To import a module
24. In – To check if a value is present in a list, tuple, etc. Returns True if the value is present,
otherwise returns False
25. Is – Used to test whether two variables refer to the same object. Returns True if the objects
are identical and False if not.
26. Lambda – To create an anonymous function
27. Nonlocal – To declare a non-local variable
28. Not – Logical operator
29. Or – Logical operator
30. Pass – It is a null statement in Python. Nothing happens when executed. It is used as a
placeholder.

Information Systems
Page 74
31. Raise – Used to create exceptions, what to do when an exception occurs, same as 'except'
and 'try'
32. Return – Used inside a function to exit and return a value.
33. Try – Used to create exceptions, what to do when an exception occurs, same as 'raise' and
'except'
34. While – Used to create loops.
35. With – Used to simplify exception handling
36. Yield – Used inside a function just like 'return', except 'yield' returns a generator.

Page 75

Information Systems
PRACTICE No. 1 My first program

Purpose: To get you to apply the basic knowledge for the creation of a
sequential program in a high-level programming language.

Knowledge:
Development:
1. Create a program in Python that allows you to print messages with the print() function
and input data with the input() function, adding comments
2. Note: If you do not have a digital device, do the exercise in your notebook.

✓ Variables ✓ input() function


✓ Comments ✓ print() function

3. Open the programming editor suggested by your teacher.


4. Write the program code with the support of your classroom teacher.

Page 76

Information Systems
5. When you finish the code, save the file in your folder with the following structure:
Practica01, initials of your name, group and shift. Example: “Practica1_GEHMAM” are
the initials of your name, A is the group and M is the shift for Morning and V for
Afternoon. If you have completed it in your notebook, it will be delivered to your
teacher for review.

6. Then press the run button and verify that the output is correct.

7. CONCLUSIONS: At the end of the practice, in your own words answer the following questions
in your notebook:
questions:

What did I learn?

Information Systems
Page 77
Where do I apply it in my daily and academic life?

Information Systems
Page 78
Assessment instrument CHECKLIST PRACTICE No. 1 My first program

GENERAL DATA
Name(s) of student(s) Registration(s)
Product: First program. Date
Subject: Period
Name of the teacher Teacher's signature

REAGENT VALUE OBSERVATIONS


CHARACTERISTICS TO BE OBTAINED CALIF AND/OR
VALUE COMPLIED WITH SUGGESTIONS FOR
YEAH NO IMPROVEMENT
2 Code correctly and respect the
program structure.
1 Please edit the comment correctly.
1.5 Apply the function print()
properly.
1.5 Apply the function input()
properly.
2 Run the program correctly.
1 Save the file with the requested
nomenclature.
1 Deliver the program on time and in
form.

QUALIFICATION

Information Systems
Page 79
CO BATA B
TABASCO HIGH SCHOOL
TABASCO
'Education that generates
change'
References

Solvetic Systems (2020). “Install Python 3.9 on Windows 10”.


https://www.solvetic.com/tutoriales/article/9130-instalar-python-3-9-en-windows-10/

Python Software Foundation (2020). Support. https://www.python.org/

ADR(2021). The Print() function in Python.


https://www.adrformacion.com/knowledge/programacion/2 print .html

Source code (2021). “Operators in Python”. https://www.codigofuente.org/operadores-en-


python/?vlogger_serie_in=1122

Unypyton (2020). “DATA TYPES AND VARIABLES IN PYTHON”. https://unipython.com/types-data-


variables-python/

Peña J. M. (2021). “What are Keywords in Python?” https://eiposgrados.com/blog-python/words-


reserved-python/

Sintes B.(2018). “Keyboard input: the input() function”.


https://www.mclibre.org/consultar/python/lecciones/python-entrada-teclado.html

Page 79

Information Systems
Instructions: Read the following text, underlining the main
ideas.
It is recommended to practice with each of the examples,
at the end complete the
suggested activity depending on your teacher's
instructions.

Conditionals are program structures that are executed depending on the result of a comparison.
Python 3 uses If, Else and Elif (More than two alternatives) as comparison structures that allow us
to execute a certain block of code, provided that one or more conditions are met.

It is very likely that in your daily activities you will face these conditions, and we can cite an
example, when you wake up you identify the day of the week, so we can assume that, if it is
Sunday, and you ask yourself the question, do I have to go to school today?, the conditional
integrated in this question will only lead us to two possible answers, Yes or No, given that we have
identified that it is Sunday, you can then deduce that the answer would be No.

Next, we will analyze the syntax of each of the Conditionals:


6.1 If statement:

In programming terms, a question determines a path to follow, so in order to structure it, Python
uses the If statement, where If is “if” followed by the condition.
The syntax of the if construct is as follows:

if condition:
Here are the orders that are executed if the condition is true and that can
occupy several lines

Information Systems
Page 80

Information Systems
The execution of this construction is as follows:
The condition is always evaluated.
If the result is True, the block of statements is executed.
If the result is False, the block of statements is not executed.
(mclibre, 2020)
FLOWCHART: IF STATEMENT

If we go back to the example, we have in Python that:

Page 81

Information Systems
The result will be:

If the variable dia were assigned something other than “Sunday”, as it has no other block than

running the program will not print output.

Whose output will be:

76 Python Shell —□X


File Edit Debug Options Windows Help

al •
interface and no data is s
ent to or received from the Internet.
k*********kkkk*******
******************** k*******

IDLE 3.0 ==== No Subprocess


ss ====

Ln: 13/4

Page 82

Information Systems
6.2. - IF…Else statement:

In cases where it is necessary to have a second block for when the condition returns “False”, in

Python this segment is defined by adding the Else statement.

Syntax of the if ... else ... conditional statement

The syntax of the if ... else ... construct is as follows:

if condition:
Here are the orders that are executed if the condition is true
and that can occupy several lines
else:
and here are the orders that are executed if the condition is
false and can also occupy several lines
The execution of this construction is as follows:

The condition is always evaluated.


If the result is True, only block 1 of statements is executed.
If the result is False, only statement block 2 is executed.

FLOWCHART: IF STATEMENT ... ELSE ...

Page 83

Information Systems
Example:
Mu1.1.0.beta.5-conditionO.py — □X

(m) (+)(±)(±) (x) (ñ (E)()(•)(~)(©)(s)(=)(2)(6)


New Mode Load Save Stop Debug REPL Tracer Zoom In Zoom Out Topic Check Tidy Help Sair

i dia="saturday"#assign value 2 if dia=="sunday" :#verify that it is ''sunday" 3 print ('I'm not going to school
condidonl.py X condicion2mayor.py X condidionO.py X

today')#instructions if the day is Sunday 4 else:#considering that he studies on Saturdays


5 print("I'm going to class")# instructions for any other day

Running: conditionO.pv

I go to classes

Python 3

It is then important to clearly define the condition to be evaluated and take


into account all possible options, in which case if there are more than two
options, it will be necessary to use Elif to link the other conditions or use
nested conditions, and until the end when none of the alternatives are met,
use Else to indicate what to do and in this way cover all possible options in our
program. Learn
more

It is important to remember that a condition is a programming calculation whose result is


either 'Yes' (True) or 'No' (False). There are certain symbols (or operators) that are used to
create conditions, such as:

Information Systems
Page 84
Source: Gonzalez (2009)

6.3. - if Elif else statement

The if ... elif ... else ... control structure allows you to chain multiple conditions together. elif is a
contraction of else if. The command in Python is written like this:

Syntax of the conditional statement if ... elif ... else ...


The syntax of the if ... elif ... else ... construct is as follows:

if condition_1:
Block 1
elif condition_2:
Block 2
else:
Block 3

If condition 1 is met, block 1 is executed


If condition 1 is not met but condition 2 is met, block 2 is executed.
If neither condition 1 nor condition 2 are met, block 3 is executed.
This structure is equivalent to the following nested if ... else ... structure:

Page 85

Information Systems
if condition_1:
Block 1
else:
if condition_2:
Block 2
else:
Block 3

You can write as many elif blocks as you need. The else block (which is optional) is executed if none
of the above conditions are met.

FLOWCHART: IF ELIF ELSE STATEMENT

Example: IF we modify the previous example and request the day of the week, considering that
there are Saturday classes and only Sunday classes are not held, using the elif function we will have
the following:

Page 86

Information Systems
For example, if the value “Tuesday” is captured, the execution will give:

Purpose: The student applies knowledge, solving a case


from everyday life

Information Systems
Page 87
Knowledge:
✓ If Elif Else
✓ Variables
✓ Input()
✓ Print()
✓ Operators

Development:
1. Create a program in Python to calculate the largest of 3 integers.
Note: If you do not have a digital device, do the exercise in your notebook.
2. Open the programming editor suggested by your teacher.
3. Write the program code with the support of your classroom teacher.
4. When you finish the code, save the file in your folder with the following structure:
Practica02, initials of your name, group and shift. Example: “Practica02_KCGLAM”
are the initials of your name, A is the group and M is the shift for Morning and V is
the shift for Afternoon. If you have completed it in your notebook, it will be
delivered to your teacher for review.
5. Next, we run the program, press the run button and take a screenshot of your
results.
6. CONCLUSIONS: At the end of the practice, in your own words answer the following
questions in your notebook: What did I learn? What are the advantages of using If
Elif Else? Where do I apply it in my daily and academic life?

Information Systems
Page 88
Evaluation instrument CHECKLIST PRACTICE No. 2 - the greatest of all

GENERAL DATA
Name(s) of student(s) Registration(s)
Product: if elif else program Date
Subject: Period
Name of the teacher Teacher's signature

REAGENT CHARACTERISTICS TO BE COMPLIED VALUE CALIF OBSERVATIONS AND/OR


OBTAINED SUGGESTIONS FOR
VALUE WITH IMPROVEMENT
YEAH NO
1 Code correctly and respect the
program structure.

3 Apply “If, Elif and Else” within the


program correctly

2 When running the program, it asks for


3 integers
2 Gets the largest number of 3 integer
values

1 Save the file with the requested


nomenclature.
1 Deliver the program on time and in
form.

QUALIFICATION

Page 89

Information Systems
References
CO BATA B
TABASCO HIGH SCHOOL
TABASCO
'Education that generates
change'

Sintes B. (2020). “if ... elif ... else”. https://www.mclibre.org/consultar/python/lecciones/python-if-


else.html

Information Systems
Page 90

Information Systems
Reading 7. Repetitive Structures

Instructions: Read the following, underlining the main ideas. When you finish, do
practice No. 3

The Repetitive control structure, also known as loops or cyclic, allows us to execute a certain block
of code repeatedly, as long as a condition is met.
Python has two cyclic structures:

1. The FOR loop


2. The WHILE loop
7.1 WHILE cyclic structure

The While statement is used to repeat blocks of code “while” a certain condition is met.
Structure of WHILE:

1. while<CONDICIÓN> :
2. <CÓDIGO A EJECUTAR>

Example: Generate a counter from 1 to 10 and print the result.

Example1-B While, py X

i # ICT Training
2 x = 0 fWe declare the value of the variable "x"
3 while (x < 10): #Create the loop with the condition to run while "x"
4sea less than "10"
5 x +=1 #Body of the repetition = we add one to x (x is equal to x plus one) and print (x) We print "x"

Page 91

Python 3

Information Systems
Result:

While Infinite
It is a While followed by a “True” (While True) that indicates that the condition will always be met.
The purpose is that the user cannot exit the loop and it does not end, until he enters a number and
chooses an option to obtain a result.
Break
This instruction is used to end a loop. That is, exit it and continue with the execution of the rest of
the program instructions and this can be used for While and For.

Page 92

Information Systems
Example 2: Create a breakfast menu using infinite repetition (While True) and when choosing an
option, execute the option, exit the option (break) and then continue the program instructions.

Ejem2-BWhileInfinito.py X

i # ICT Training

2 while True: #We create the infinite loop


option = (input('""'Choose a type of breakfast:
1- English breakfast
2- Continental breakfast
3- American Breakfast
Yo . ))#We create an input for the user to enter their option and store it in "option"
#----Conditional depending on the option you choose---------
if option == '1':
print ("Consists of Fried eggs, beans, mushrooms, coffee or tea")
break We break the loop
elif option == '2':
3
print ("Consists of Toast, jam, coffee or tea and juice")
4
break #We break the loop
5

6
elif option == '3':
7 print ("Consists of 2 eggs, sausage, pancakes, coffee or tea and juice")
s break #We break the loop
9 else:
10 | print ("You must select an option (1, 2 or 3)")
11 print("Order Received, enjoy your breakfast...") #We add a print OUTSIDE THE LOOP to end
12
Note: The variable “option” is of text type, the while loop requests to choose an option from
13

14
menu 1, 2 or 3, otherwise if you type another number or letter, it will repeat the menu until
15

16
you choose the correct option. The if conditions are between '1' apostrophes because they are
17

18
text type, you can also use “1” quotation marks.
19

20

Information Systems
Page 93
Result:

7.2. - FOR cyclic structure

The FOR statement is used to repeat a block of code, but unlike the WHILE statement where it
depends on a condition (TRUE, FALSE), the FOR loop ends when it has no more elements to iterate
through.
FOR structure:
1. FOR<elemento> IN<elementos a iterar> :
2. <CÓDIGO A EJECUTAR>
Example 1: Create 3 lists. List from 0 to 5, List between 10 to 20 and List of multiples from 5 to 50
and a list that uses the character length of a text string and the variable goes through taking each
value.

Page 94

Information Systems
Result

Page 95

Information Systems
PRACTICE 3 -Calculate the average of 3 grades

Purpose: Identify and apply the advantages of using repetitive structures


or loops for problem solving or academic exercises and

professionals.

Knowledge:
✓ For Structure
✓ Loop control
✓ While Structure
✓ Break
✓ Infinite While Structure
✓ Conditions

DEVELOPMENT
8. Create a program in Python to calculate the average of 3 grades.
Note: If you do not have a digital device, do the exercise in your notebook.
9. Open the programming editor suggested by your teacher.
10. Write the program code with the support of your classroom teacher.
With the repetitive structure: WHILE

Information Systems
Page 96

Information Systems
With the repetitive structure: FOR

11. When you finish the code, save the file in your folder with the following structure: Practica03, initials of
your name, group and shift. Example: “Practica03_KCGLAM” are the initials of your name, A is the
group and M is the shift for Morning and V is the shift for Afternoon. If you have completed it in your
notebook, it will be delivered to your teacher for review.
12. Next, we run the program, press the run button.
Example:

Information Systems
Page 97
COBATAB
TABASCO HIGH SCHOOL
TABASCO
“Education that generates
change”
13. CONCLUSIONS: At the end of the practice, in your own words answer the following questions in your
notebook: What did I learn? What are the advantages of using the For and While cycles? Where do I
apply it in my daily and academic life?

Page 98

Information Systems
CO BATA B
TABASCO TABASCO HIGH SCHOOL

“Education that generates


change”
Assessment Instrument CHECKLIST
PRACTICE No. 3- Calculate the average of 3 grades

GENERAL DATA
Name(s) of student(s) Registration(s)
Date
Product: Repetitive structure program (FOR or WHILE)
Subject: Period
Name of the teacher Teacher's signature

REAGENT VALUE OBSERVATIONS AND/OR


CHARACTERISTICS TO BE OBTAINED CALIF SUGGESTIONS FOR
VALUE IMPROVEMENT
COMPLIED WITH
YEAH NO
1 Code correctly and respect the
program structure.
2 Apply the “while or for” loop within
the program correctly

1 Initialize the variables


corresponding and applies them
appropriately.
2 Requests all 3 ratings when running
the program.
2 Calculate and display the average of
the 3 grades correctly.
1 Save the file with the requested
nomenclature.
1 Deliver the program on time and in
form.

QUALIFICATION

04

Information Systems
Page 99
CO BATA B
TABASCO HIGH SCHOOL
TABASCO
'Education that generates
change'
References

Sintes B. (2020). “For loops”. https://www.mclibre.org/consultar/python/lecciones/python-for.html

Sintes B. (2020). “While loops”. https://www.mclibre.org/consultar/python/lecciones/python-while.html

Page 100

Information Systems
Ib—
Reading 8 Lists and
Instructions: Read the following, analyze the structures for treating lists, and when you
finish, do practice 4.

Among the many types of data structures that Python has, lists are one of the most used, since they are
very versatile as they allow storing data regardless of its type; Moya, R. (2015) defines lists as:

They are a very flexible type of data structure that stores in an orderly manner a set of data that
does not have to be of the same type. In other programming languages a list would be equivalent
to an array, although Python does not require that the elements of the list have to be of the same
type ('int', 'float', 'chr', 'str', 'bool', etc.').

So we can say that a list is an array of elements in which we can have integers, floats, text strings, booleans,
and even other lists within it. To create a list we only have to give it a name (like any variable), place each of
its elements in brackets and separated by commas.
Figure 1 Creating lists in python3

masuaa-mamsmma r)(+)(2)(±)(•)(*)()()()(C • ? b New Mode Download Save Run Debug REPL Zoom In Zoom

Out Topic Check Help Exit 207 X 1p X creocondelistayopoonespy X Cresrlotapy X sndodo* X 1 Creating a list 2
3 list=[10,8.5,"python3",[1,2,"list"],"etc"]

Note: within the list there are different types of data, from left to right: int, float, str, list, str.
4 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- praying

Information Systems
Page 101
Although we can create a list with all the information we could use (see figure 1), it is also possible to create
a blank list and, using the input function and some methods used in lists, add the data we need.

Accessing and viewing the contents of a list is easy, using the print function either to see the entire content,
or a specific item.

Figure 2 Displaying all items in the list

Note: The print(list name) function sends all the elements contained in the list to be displayed on the screen.
Figure 3 Displaying specific items in a list

Note: with the print(list name [element index]) function, a specific element is sent to be displayed.

Page 102

Information Systems
Within the lists, the indexes of the elements start at 0, so the first element within this will have this index,
the second index 1, the third index 2, etc.

Another way to access and display all the elements found within the list is by using the for loop.

Figure 4 Displaying all elements of a list using the for loop

Note: with for we can go through all the elements of the list and then display them with print, in this case the elements
are shown in a descending list.

In order to work with lists, Python has specific methods, some of them similar to those used with str text
strings. These methods will allow us to add data, delete it, know its indexes, count repetitions, invert them,
etc. Python Software Foundation (2021a). There are eleven methods for working with lists in Python3, but
we will only work with the most commonly used ones.

Information Systems
Page 103
Table 1
Most used methods for working with lists in Python3

Method Function Syntax

.append Adds a new item to the end of the list. list.append(item)

Add items within a list, but unlike append


.extend list.extend([item,item])
when adding them, they must be within a list.

Adds an element at a given position or index.


.insert list.insert(index, element)

Removes a specific element from the list by


entering the value of the element. If the
.remove element does not exist, send a ValueError list.remove(item)

message.

.clear Remove all items from the list list.clear

Returns the index of the element that we

.index place as a parameter. If the element does not list.index(item)


exist, send a ValueError message.

Displays the number of times the element we


.count list.count(item)
use as a parameter is repeated.

.reverse Inverts the elements of the list. list.reverse()

Note: Own creation. Based on: Python Software Foundation (2021b), Mariños, J.(sf), Gónzalez,
R.(2011).

Page 104

Information Systems
Below are examples of the methods listed in Table 1, for these examples the list “names” will be used:

Figure 5 Method. append

Figure
6

Note: The "Carlos" item is added to the end of


the .extend Method list

Note: The elements "Armando" and "Manuel" are added at the end.

Information Systems
Page 105
Figure 7 .remove method

Note: The element being removed is within the .remove parameter, in this case it is
"pedro".

Figure 8 .clear method

Note: All elements of the list are removed, however, the list still exists and when
viewed with print the empty brackets appear.

Information Systems
Page 106
Figure 9 .index method

Note: Returns the index value of the indicated element, in this case the element "juan" is
located at index 1.

Figure 10 .count method

Note: Returns the number of times an element is repeated, in this case the element "juan" is
repeated 2 times.

Information Systems
Page 107
Figure 11 .reverse method

Note: Displays items in reverse order.

Now that you know what lists are and the most commonly used methods for working with them,
let's put this new knowledge into practice.

Example 1

We will create a blank list (it is recommended that the name of the list refers to the elements it
contains) and through the .append method we will enter elements into it. It is necessary to create
a variable so that with this and the input function we can enter the elements of our list using the
keyboard.

Information Systems
Page 108
Figure 12 Creating an empty list, variable for data entry and using the .append method.

Note: the elements entered into the list are displayed using the print function.
Now, using loops we could enter a certain number of elements; if we want to determine how many
elements we want to enter before displaying our list we can use the for a loop as shown below:

Figure 12 Creating an empty list, variable to determine the number of elements we want to enter
and using the for loop.

From this example you can create a program in which you manipulate a list with the different
methods and loops that you have worked on throughout the submodule.

Information Systems
Page 109

CO BATA B
TABASCO HIGH SCHOOL
TABASCO
'Education that generates
change'
Arrangements

The data structures we have seen so far (lists) allow us to manipulate data in a very flexible way. By
combining and nesting them, it is possible to organize information in a structured way to represent
real-world systems.

In many engineering applications, on the other hand, more important than the organization of data
is the ability to do many operations at once on large sets of numerical data efficiently. Some
examples of problems that require manipulating large sequences of numbers are: weather
prediction, building construction, and financial indicator analysis among many others.

The data structure used to store these large sequences of numbers (usually of float type) is the
array.

Arrays have some similarities to lists:

• The elements have an order and can be accessed by their position,


• Elements can be traversed using a for loop.

However, they also have some restrictions:

• All elements of the array must have the same type,


• In general, the size of the array is fixed (they do not grow dynamically like lists),
• They are mainly used to store numerical data.

Arrays are the programming equivalent of matrices and vectors in mathematics. Precisely, a big
motivation for using arrays is that there is a lot of theory behind them that

Page 110

Information Systems
can be used in the design of algorithms to solve truly interesting problems.

Create arrangements
The module that provides the data structures and functions for working with arrays is called
NumPy, and is not included with Python, so it must be installed separately.

Download the appropriate installer for your version of Python from the NumPy downloads page.
To see what version of Python you have installed, look at the first line that appears when you open
a console.

To use the functions provided by NumPy, we must import them at the beginning of the program:

from numpy import array


Since we will be using many functions from this module frequently, it is convenient to import them
all at once using the following statement:

from numpy import *


(If you don't remember how to use import, you can review the material on modules).

The data type of arrays is called array. To create a new array, you can use the array function
passing it as a parameter the list of values you want to add to the array:

>>> a = array([6, 1, 3, 9, 8])


>>> a
array([6, 1, 3, 9, 8])
All elements of the array have exactly the same type. To create an array of real numbers, one of
the values just needs to be real:

Information Systems r
Page 111
>>> b = array([6.0, 1, 3, 9, 8])
> >> b
array([ 6., 1., 3., 9., 8.])

Another option is to convert the array to another type using the astype method:

> >> a
array([6, 1, 3, 9, 8])
> >> a.astype(float)
array([ 6., 1., 3., 9., 8.])
> >> a.astype(complex)
array([ 6.+0.j, 1.+0.j, 3.+0.j, 9.+0.j, 8.+0.j])

If you want to know more about the treatment of arrangements, we provide you
with the following QR or open the following URL:
http://progra.usm.cl/apunte/materia/arreglos.html

Information Systems
Page 112

Information Systems
Practice 4 List manipulation

Purpose: Create an empty list which, through the methods studied


can be manipulated to add and remove elements from it; as well as
make use of the while and for loops, and the conditional statements studied.

Knowledge: lists, methods for list manipulation, while and for loops, if, elif, else conditional statements,
break statement.

Instructions:
1. Take the reading example as a basis.
2. Modify the program by adding loops and conditional statements
3. Consider that the program takes an empty list as a base, it should ask for the number of
elements that we want to enter, show the list and ask if we want to enter another element.
4. You must request the removal of at least one item
5. You should have the option to exit the program.

Consider that the solution depends largely on the use of each sentence seen, the application of these
depends on your reasoning ability and your creativity.

Information Systems
Page 113

Information Systems
Assessment Instrument CHECKLIST Practice 4 “List manipulation”

GENERAL DATA
Name(s) of student(s) Registration(s)
Product: Practice 4 Date
Subject: Period
Name of the teacher Teacher's signature

REAGENT CRITERIA TO BE FULFILLED VALUE OBTAINED CALIF OBSERVATIONS


AND/OR
YEAH NO SUGGESTIONS FOR
1 Create an empty list 0.5 IMPROVEMENT
2 There is a variable to indicate the 1
number of elements to enter in the
list
3 It uses the for loop to enter 2
elements into the list.
4 Elements are entered via the 0.5
keyboard (input)
5 It uses conditional statements to 1
choose actions for entering and
removing elements, as well as for
exiting the program.
6 It uses the while loop to continue or 2
stop the program.
7 It makes use of the .append 2
and .remove methods to add new
elements and remove elements
8 In all cases the contents of the list 1
are displayed without errors.

QUALIFICATION

Information Systems
Page 114
CO BATA B
TABASCO HIGH SCHOOL
TABASCO
'Education that generates
change'
References:

Moya, R. (April 6, 2015). List in python, with examples. Jarroba.com. https://jarroba.com/list-


python-examples/

Python Software Foundation (2021). More about lists. Data structure. Documentation.
https://docs.python.org/es/3/tutorial/datastructures.html#more-on-lists

Gonzalez, R. (2011). Lists. Reviewing objects. Python for everyone.

Marinos, J.(sf). Lists in python. Devcode. https://devcode.la/tutoriales/listas-python/

Page 115

Information Systems
Systems Development
Student Teaching Guide

Graphical interfaces with Python 3

Python 3 has the functionality to create graphical interfaces (GUI), for this it
uses libraries, the easiest one that comes preloaded in the installer, and that is
multiplatform is Tkinter (tk). Labels and their use require a bit more
specialization, as an example, and to familiarize you with them we present the
creation of a window using this library.

Suarez and Suarez (2015) present us with the following basic example.

#!/usr/bin/env python
# -*- coding: utf-8 -*-

# The following two lines are necessary to do


# Tkinter interface compatible with programs based on
# in versions prior to 8.5, with the most recent ones.

from tkinter import * # Load tk module (standard widgets)


from tkinter import ttk # Load ttk (for new widgets 8.5+)

# Defines the main window of the application

root = Tk()

Defines the dimensions of the window, that will be in


located
the center of the screen. If omitted This line is
window will adapt to the widgets that are placed in
she.

# root.geometry('300x200')# width x height


#
# # Assign a background color to the window. If
# omitted
# this line the background will be gray root.configure(bg = 'beige')

# Assign a title to the window

root.title('Application')

# Defines a button at the bottom of thewindow


# which when pressed will terminate the program.
# The first parameter indicates the name of the 'root' window

Block name
Page 117
Systems Development
Student Teaching Guide

# where the button will be located

ttk.Button(root, text='Exit', command=quit).pack(side=BOTTOM)

# After defining the main window and a widget button


# the following line will cause when executed the program
# build and display the window, leaving it at the waiting
for
# that someone interacts with it.

# If the person presses the Close button 'X', or good,


# on the 'Exit' button the program will arrive atits end.

root.mainloop()

whose program output in Windows is:

You can learn more about graphical interfaces at the following link:
https://python-para-impacientes.blogspot.com/2015/12/
tkinter-interfaces-graficas-en-python-i.html

or at: https://www.youtube.com/watch?v=Nn0AVbGVMhk

Block name
Page 118
Systems Development
Student Teaching Guide

Reference

Suarez and Suarez (2015). Tkinter: graphical interfaces in Python. https://python-para-


impatients.blogspot.com/2015/12/tkinter-interfaces-graficas-en-python-i.html

Block name
Page 119

You might also like