Rivera Medina Paola Sofía Robotics 2ºC May 11th, 2024
Universidad Politécnica de Yucatán
Structural Programming
Puerto Adrián
Robotics 2ºC
Rivera Medina Paola Sofía
May 11th, 2024
1
Rivera Medina Paola Sofía Robotics 2ºC May 11th, 2024
HOMEWORK 1 – U1
Universidad Politécnica de Yucatán
Subject: Structured Programming
Instructions: Review the references and do what is requested in each point. For each
of the exercises it is necessary to generate evidence taken directly from your computer.
Cut-off date: 11/05/24.
1. Install the programs used in reference 1.
This first video shows how to install the Python program for Windows from its official
website (https://www.python.org/). From here, I noticed that the Python version of the
video was older than the version I was going to download. I clicked the “Python 3.12.3”
button, and the download started automatically.
When you click on the downloaded file, a window automatically appears to finish
installing the program.
I couldn't find where the program was installed, until I searched for it in the search
bar. I opened the program and created a shortcut on my desktop.
2
Rivera Medina Paola Sofía Robotics 2ºC May 11th, 2024
The next step is to install the Visual Studio Code on its official website
(https://code.visualstudio.com/) by clicking the “Download for Windows” button.
Click on the downloaded .exe file, accept the terms and conditions, install it and
when finished, let the program run once the installation is ready
When you run the program, a customization section starts. The only thing changed
was the program's color theme. The other configurable details were left at “default” to
avoid confusion or problems.
The Python “extension” is installed in the “Extensions” tab. Once installed, you can
go to the “Explorer” tab where a folder and a file ending in “.py” will be created.
3
Rivera Medina Paola Sofía Robotics 2ºC May 11th, 2024
Once inside the.py file, the terminal opens where we will write a command to
verify the correct installation of the Python extension. To open the terminal, use Ctrl +
Shift + ñ. The command for verification is “$ py -3 -version”, but I get the
following error:
$ : El término '$' no se reconoce como nombre de un cmdlet, función, archivo de script o
programa ejecutable. Compruebe si escribió correctamente el nombre o, si incluyó una ruta
de acceso, compruebe que dicha ruta es correcta e inténtelo de nuevo.
After some research, I discovered that the way to verify the installation of the
extension is to simply type in the terminal “Python”. Thus, the version of Python that is
being used appears and right there we can put the commands that we will use.
To exit or “close” the Python command, type the quit() or exit() commands in
the terminal. To reopen it, type Python again in the terminal.
4
Rivera Medina Paola Sofía Robotics 2ºC May 11th, 2024
The Python command can be used as a calculator for simple operations, such
as addition, subtraction, multiplication, and division. All this by simply writing the
operation you want to perform. At the same time, variables can be defined.
To run the code that is written in the file (and not in the terminal), click the button
that looks like a triangle that says “Run Python File”, or enter Python “File name”
in the Python terminal. My file is called “main.py” = Python main.py.
Thus, the instructions of the first video are finished.
5
Rivera Medina Paola Sofía Robotics 2ºC May 11th, 2024
2. Copy the most relevant information and perform the exercises carried out in
reference 2.
In this second video we are taught that variables can be defined and changed. An
example is assigning a value to an unknown variable and then doing a mathematical
operation with them.
But in the "C" programming language the definition of variables is different. Here,
you must declare the variable before using it using "int x; x = 10", thus specifying
the type of value, in this case an integer value.
In Python you have more freedom when defining and using variables. For example,
if we define "x" and "y" with certain values, we can change the value of any of the
variables without problems.
In C, variables must be previously specified and with an indication of what type of
variable it is so that, during its useful life, it remains static.
int x = 10; #Variable of type integer
x = 4.55; # We cannot assign another value
In Python there is no need to be specific before using a variable and it can have
different values during its lifetime. The variables are dynamic.
x = 10
x = 4.55 #Now we can change its value without problem.
Thus, the instructions of the second video are finished.
6
Rivera Medina Paola Sofía Robotics 2ºC May 11th, 2024
3. Copy the most relevant information and perform the exercises carried out in
reference 3.
Variable naming conventions is naming variables according to five rules.
Rule 1. Variable names can only contain letters, numbers, and underscore. NO special
characters allowed.
Rule 2. The variable name can start with a letter or underscore, but never with a
number.
Rule 3. Spaces are not allowed in variable names, use underscore instead.
Rule 4. Variable names should be short and descriptive, but understandable.
Rule 5. Variable names are case sensitive (Upper case and lower case).
7
Rivera Medina Paola Sofía Robotics 2ºC May 11th, 2024
There are Multi Word Variable Names, which are different forms of nomenclature
for variables:
• Camel Case Convention: Second and following words are capitalized.
Example: studentName
• Pascal Case Convention: The same as Camel Case Convention, but the first
word also has a capital letter.
Example: StudentName
• Snake Case Convention: Words separated by an underscore.
Example: student_name
Greater use will be made of the Snake Case Convention.
Chained Assigment of Variables is giving the same value to several variables on
the same line.
Thus, the instructions of the third video are finished.
8
Rivera Medina Paola Sofía Robotics 2ºC May 11th, 2024
4. Copy the most relevant information and perform the exercises carried out in
reference 4.
• Variables in C:
In the C programming language, the following is used for variables:
Data_type variable_name = value;
Int x = 10; Int y = x;
Thus, the value of x is stored in memory. A variable is a name of some memory
location.
• Objects in Python
− Every data item is object in Python.
− An object is an entity that contains data along with properties and behavior
(object would be like a package that has data and its properties and behaviors).
− An object refers to a specific blueprint called class.
− Difference between class and object:
Person (Class) Adam (Object)
Properties Behaviour Properties Behaviour
name walking Dan walking
age eating 24 eating
gender sleeping male sleeping
• Variables in Python
In the Python programming language, a variable is defined as a label that is given
to some object. The following is used to define variables:
Varable_name = object;
x = 10; y = x;
Thus, finishing the instructions of the fourth video.