You are on page 1of 24

Linear Algebra

Laboratory Activity No.1

Python Fundamentals

Submitted by: Instructor:


Cortes, Patrick Alvin A. Eng. Eugene H. Embalzado Jr.
Takeuchi, Joshua S.

February 22, 2022


I. Objectives
The goal of this lab activity is to use the concepts and practices of Google Collab in the
field of programming to make it more efficient and effective. The students had a greater
understanding of how to use codes as a tool to help them, as well as practice interpreting various
meanings using codes. It's also a wonderful approach to get students acquainted with the basics
of Python.

II. Methods
These lessons were achieved through the use of imitation and following the instructor via
virtual classroom setting. Initially, Google Colab and GitHub were introduced by the instructor
as an application in formatting different methods in Coding Python. Moreover, different
techniques were also utilized upon engaging in learning the meanings behind the variations of
codes. By practicing coding, the students were able to learn variables and data types, Operations,
Arithmetic, Assignment Operations, Comparators, Logical, Input and Output, Looping
Statements which includes While and for. Also, Flow control under conditions statements and
Functions were the last discussions upon using Google Colab.

Descriptions of different types of codes were learnt and able to recognize the implication
of each format. Practically, variables and data types were introduced since it is used for
declaring, describing and performing mathematical functions that were provided by the
programmer. Under Operations, there are two different subtypes which include Arithmetic that
basically presents mathematical operations like division, multiplication, subtraction, addition,
Floor Division, Exponentiation, and Modulo, and Assignment Operations that helps expression
or values to be kept as an input in order for to run a certain code. Furthermore, Comparators
were introduced to help us in comparing values or proving whether to decide the relationship
among the two variables.

Moreover, Logical inputs were used to compare the values in terms of their set
relationship as a rule to indicate knowledge into a program by the application of reason based on
facts and inputs by the provider. In addition, Input and Output function is a predefined set of data
for printing text during runtime. Looping statements were used to execute a block of one or more

2
statements for a set number of times or as long as a condition is true. The “for” and “while”
codes were used to introduce looping statements. Moreover, the flow control where the last topic
utilized for conditional statements is used to handle conditions in your program, as the name
implies. These statements guide the program as it makes judgments based on the circumstances it
encounters.

III. Results

Variable and Data Types

Figure 1.1 ( Assignment of Values)

This type of data describes that the x is assigned to a value with a and b set at two
different values respectively.

Figure 1.2 ( Class Type Description)

This figure shows that type() describes the class type of a variable given as an input
wherein the (a) is the variable and after running it shows integer as given below.

3
Figure 1.3 ( Assignment of Variable “y”)

In this figure however, the variable y was assigned as an integer. But since the “y” had
been an input for type() so it was classified as a float since it was identified and converted into a
number.

Figure 1.4 (Assignment of float as “x”)

As shown in this figure, the float (x) has been assigned as the “x” variable and below the
cell. Moreover, an x variable has been assigned above the figure (see figure 1) and this indicates
that the x executing here was the “x=4”

Figure 1.5 ( Displaying String from type(s))

This figure shows that there are a sequence of characters and each of these letters were
assigned at their corresponding values, respectively. Hence, that calling out type(s) would
indicate that it is a string(str).

4
Figure 1.6 (Int() function)

Figure 16 shows the int()function where the variable enclosed in the parenthesis will
return into an integer.

Operations

Arithmetic

Figure 2.1.1 (Variables to be used in Generating Codes)

This figure represents the values given by their respective variables to indicate which are
to be used in generating a code. Moreover, we can see here that the letters are separated by the
comma and there is an equal sign where on the other side are the corresponding numbers of the
letters on the left side.

Figure 2.1.2 (Subtraction Arithmetic Operation)

In this figure the #Addition indicates that the arithmetic operation that will be used is
addition and S stands for the sum followed by the equal sign, on the other side there is t+a which
means that the equivalent value of those letters will be added then lastly type S to show the sum.

5
Figure 2.1.3 (Subtraction Arithmetic Operation)

It shows here that the ###Subtraction indicates that the arithmetic operation that will be
used is subtraction and D stands for the difference followed by the equal sign, on the other side
there is a-i which means that the equivalent value of those letters will be subtracted then lastly
type D to show the sum.

Figure 2.1.4 (Multiplication Arithmetic Operation)

As we can see here ###Multiplication indicates that the arithmetic operation that will be
used is multiplication and P stands for the Product followed by the equal sign, on the other side
there is t*i which means that the equivalent value of those letters will be multiplied then lastly
type P to show the product.

Figure 2.1.5 (Division Arithmetic Operation)

In this figure we can see that ###Division indicates that the arithmetic operation that will
be used is Division and Q stands for the Quotient followed by the equal sign, on the other side
there is t/a which means that the equivalent value of those letters will be divided then lastly type
Q to show the quotient.

6
Figure 2.1.6 (Floor Division Arithmetic Operation)

In this figure we can see that ###Floor Division indicates that the arithmetic operation
that will be used is Division and FQ stands for the Floor Quotient followed by the equal sign, on
the other side there is t//a which means that the equivalent value of those letters will be divided
then lastly type Q to show the quotient and every time the code is runned it will continuously
divide. In simple terms, it is the operation used to determine the remainder.

Figure 2.1.7 (Exponentiation Arithmetic Operation)

In this figure we can see that ###Exponentiation indicates that the arithmetic operation
that will be used is Multiplication and E stands for the Exponent followed by the equal sign, on
the other side there is t**a which means that the equivalent value of those letters will be
Multiplied then lastly type E to show the Exponent and every time the code is runned it will
continuously multiply.

Figure 2.1.8 (Modulo Arithmetic Operation)

The figure above represents modulo(### Modulo) to identify the remainder of a certain
value. It is represented as “%” to determine the remainder by means of getting its ratio between
two variables. In simple terms, it is the operation similar to division but is used to determine the
remainder instead of its quotient.

7
Assignment Operations

Figure 2.2.1 (Assignment of Values)

We can see here that the letters are separated by the comma and there is an equal sign
where on the other side are the corresponding numbers of the letters on the left side. This implies
that there are values assigned for each variable to rule out their corresponding codes when
generated.

Figure 2.2.2 (Assigned letters for Adding)

It is shown here that the letter J is added to the equivalent value of t then we type J to get
the answer. The variable “J +=” describes that the value given for “J” is to be assigned for adding
the value for “t” variable. However, this also shows that every time we run the values or in short
“Continuous Increment” and hence, will be added continuously until whether positive or
negative infinity.

Figure 2.2.3 (Assigned letters for Subtracting)

8
It is shown here that the H is subtracted to the equivalent value of i then we type H to get
the answer. Moreover, the expression “H -=” indicates that the “H” value will be subtracted to
the value assigned for the variable “i”. And this figure is also an indication for “Continuous
Decrement”.

Figure 2.2.4 (Assigned letters for Multiplication)

It is shown here that the S is multiplied to 7.0 then we type S to get the answer and every
time we run the code the answer will be multiplied to S or to the product.

Figure 2.2.4 (Assigned letters for Exponent)

It is shown here that H was exponentiated to a value of 2 so it will be continuously


exponentiated until infinity.

Comparators

Figure 3.1 (Assignment of Variables)

9
In this figure the values are assigned and separated by comma and there is an equal sign
to represent the equivalents of the res_1,_2, and _3, on the other side with three different
coefficients, respectively.. Moreover, the “true_val” was assigned to be as a real value for
comparison which was set to “1”.

Figure 3.2 (Comparing res_1 to true_val)

It is shown here that we are looking if the comparator is right. Here we can see that = is
used to identify if res_1 is equal to true_val, hence, it will be true since the “true_val” and
“res_1” were equivalent and only necessary for the program to call it out as “true”.

Figure 3.3 (Comparing res_2 to true_val)

It is shown in this figure that we are looking to see if the comparator is right. Here we can
see that ! is used to identify if res_1 is not equal to true_val, and yes it is not equal so the answer
is true.

Figure 3.4 (Checking if the Comparator is Right)

10
It is shown here that we are looking if the comparator is right. Here we can see that there
are 4 trials t1, t2, t3, and t4. In t1 it is said that res_1>res_2, and for t2 =res_1<res_2/2, while
t3=res1>=res_2/2, and lastly t4 which is res_1<=res_2 and the answers to all the trials is true. In
addition, the table shown above was expressed in terms of their inequality and proving whether
the said expression is true or false. Based on the code provided, the “t4” was called out at the
very end and so the program would process that there was a variable “t4” with a statement of
comparison to prove what “res_1<= res_2” be given by their respective values above.

Logical

Figure 4.1 (Whether res_1 is Equal true_val)

From the past subjects that were discussed, logical statements are used to prove whether
true or false based on the rules given by the provider. It could be disjunction, conjunction,
negation, etc. Given by the assigned variables from the comparators, these statements will also
be included for comparators, for instance “res_1 == true_val” is true since that two variables
were equated as an expression and it resulted as “True” since two values are equal.

Figure 4.2 (Whether res_1 is true_val)

In this figure, we know that “res_1 is not true_val”. However, using a logical statement to
further prove the statement, adding “is” will be necessary since we ruled out and assume that
both variables are equal. Therefore, the program answered “false” since they are not equal. As It

11
is shown here that the res_1 is said to be the true_val but the answer is false because the true_val
is 1.0.

Figure 4.3 ( Whether res_1 is not true_val)

The figure above entails as shown here that the res_1 is said to be not equal to the
true_val and the answer is true because the true_val is 1.0 and not res_1. It was programmed that
“res_1 is not true_val” and it will respond as “true” since logically speaking, res_1 will never be
true_val”.

Figure 4.4 (Conjunction Statements)

As this figure shows, conj is expressed for conjunction statements and these statements
tell us that it will only be true if two premises are true, otherwise, it will be false. In addition, p
and q are the two variables to be assigned as two premises of true or false. The conjunction
statement of p and q are conveyed as “ p and q” since the logical symbol for conjunction is “and”
and the program would know that the programmer was calling out conjunction for logical
statement by typing “conj” at the very end so running it would respond to “false” since that
conjunction would only be true if two premises were true.

12
Figure 4.5 (Disjunction Statements)

In comparison to the figure above, the symbol “disj” means Disjunction and is expressed
as “or” in python format. Moreover, it is the opposite description for conjunction which basically
means that two functions would only be false if two premises are both false. Hence, the input
above shows the whole idea of proving disjunctions statements. For instance, two functions and
variables were utilized to generate that “p, q” as true or false and disj were assigned as “p or q”
for disjunction statements. Therefore, the program would read it as true since two premises are
true and false.

Input/Output

Figure 5.1 (Input for Printing)

In the first figure given above, it is just basically an input for printing[print()]phrases with
an inclusion of quotation marks for creating texts inside a running program.

Figure 5.2 (Count set)

This figure elicits the count which was set to 1.

13
Figure 5.3 (Using String and Print)

In this figure, the string was called out as “play valorant” to input it as a text when
running the program. Moreover, print was also called out including the string above and
“,Current run count is :” and ending it with a variable “,cnt”. This means that printing phrases
including strings with an output of count would result in a combination of phrases and inputting
data types and variables.

Figure 5.4 (Using String, Print, and Current Count)

This figure given above, also similar in the inclusion of data types and variables as well
as the starting. However the only difference is that the count at the end resulted in a value of “2”.
The expression “current count is: {cnt}” means that we have a continuous increment of “1” and
it was further run so it will move to a value of “2”. Moreover, the “f” represents the value of “2”
in count and without it, it would only print the “current count is: {cnt}”.

Figure 5.5 (Assignment of Functions)

14
Given the figure above, “Valo_stand=1000” and “name=”taki”” was assigned as a
function for the print format by including it inside the parentheses in order for the phrase and the
name to exist once the program is run. Therefore, similar to the data types and variables, the
program responded “Play, Taki your valorant standing is :{1000})1000.

Figure 5.6 (Weights of Semestral Grades)

In this figure, it entails the different weights of semestral grade by putting an array of
w_pg, w_mg, and w_fg with their respective values of 0.3, 0.3, and 0.4. Moreover, this part
focuses on the input of a new line (\n) and a tab (\t) inside the print operator. It is utilized for
printing new lines and tabs for every phrase to be added after the “\n\t”.

Figure 5.7 (Adding Text of “enter a number”)

This figure focuses only on the input of numerical coefficients by simply adding a text of
“enter a number” and then calling out x at the bottom. This will let you answer after running it
and the program will automatically respond to what your answer will be.

15
Figure 5.8 (Functions for Every Input and Setting Variables for Printing Format.)

This figure shows that we put a function for every input and setting variables for printing
format. As for the example given above, the name has been assigned as an input (“My name is”).
Moreover, three functions were used to determine the prelim, midterm, and finals grade as an
input function. For the sem_grade, 80 highlighted to be the semestral grade at the bottom part.
Lastly, with the input functions given, Print function was used to include “Hello, your semestral
grade is{}” with its format of “(name, sem_grade)”. Therefore, the programmer was able to
answer the following inputs and at the bottom part the semestral grade has been included as
“Hello Taki, your semestral grade is :80”.

16
Looping Statements

While

Figure 6.1 (While Loops)

This figure, uses the while loops or ## While loops to be assigned as a conditional statement to
set as a rule that varies from the given variable if i and j. For instance, the variables i and j have
0 and 10, respectively as their values. Meanwhile, we have a condition of “while(i<=j) which
means we want to set a rule that zero is “less than or equal to 10”. Moreover, printing was used
in order for the programmer to input an “f string” and the function of “i/t | /t{j}”. Lastly,
continuous increment was used to apply the first ten digits added into the program. Therefore,
the “i function” has been included from 0 to 10 and the “j function” was retained from top to
bottom.

17
For

Figure 6.2 (Looping Statements to Use a Rule or Condition)

As this figure shows, for looping statements were added to use a rule or condition given that
“for(int i = 0 ;i<10;i++){#printf(i)#}In addition we set “i” to have a range of 11 values by using
the “for” looping statement. So we have a values 0 to 10 because that is within the range of 11
values and integers were also called out by using “i=0, i<10, and i++”, so the program
understand that integers set to a less than of 10 with a starting value of zero and adding a number
since “i++” operand was added.

Figure 6.3 (Input, Output of Playlists)

18
This figure entails that it is just a simple input and output of playlist and printing including
phrases and tabs with “for '' looping statements. Moreover this is an addition to a condition that
the programmers have set since we added “for” to call out the playlist above to be presented at
the bottom of the program.

Flow Control

Condition Statements

Figure 7.1.1 (Flow Control)

This figure shows the flow control, and the details show the functions “numeral1” and
“numeral2” variables with a value of 12 and 14 respectively. With the addition of conditional
statements of “if and elif” operators, ruling out that if numeral1 and numeral2 are equal, the text
presented will have the output of “yes”, and if else that numeral1 is greater than numeral2, there
should be an phrase of “uhmm” shown at the program, and otherwise or else, “HIHI” is
presented after the program will understand what the functions are after running it.

19
Functions

Figure 7.2.1 (Delete Function)

This figure discusses that in a Python program, [1234567]functions are code chunks that can be
used repeatedly. By supplying their name, you can invoke functions from anywhere in a
program. You can utilize functions in your application as many times. For instance, calling out
the delete user id inside the print function. After running the code, the “successfully deleted user
:{}” and :successfully deleted all users” will be called out and the “format(userid)” would
indicate the 202014282 userid variable and what the userid is will be deleted since a function of
“delete_user” is the input shown above the figure.

20
Figure 7.2.1 (Return Statement)

In this figure, Return statements [1234567] allow us to exit a function while also
returning a value to the function's caller. They force a function's execution to halt and the value
to be passed to the statement that invoked it. Even if you added code after the return statement, it
would not be performed because the control would leave the method. For instance, “def
add(addend1, addend2) was called out and printed inside as “I know how to add addend1 and
addend2” and return to “addend1 + addend2'' to indicate that we want to add the values of
addend1 and 2. Moreover, the “power_of_base2(exponent)” is a function the programmer wants
to call out and returning the operation of “2**(exponent)”. Furthermore, addend1, addend2, and
an exponent of 5 has a variable of 4, 8, and 5, respectively. After running it, there will be a
phrasing “I know how to addend 1 and addend 2” and a 32 since the add and power was called
out at the bottom part. Lastly, the “add(addend1, addend2)” expression was ran and resulted to
have a phrase
“ I know how to addend 1 and addend2” and a sum of 12

21
Grade Calculator

Figure 8.1 (Semestral Grade Calculator of Cortes and Takeuchi)

In the last part of the result, the instructor gave an activity in doing a calculator for
semestral grades. In this figure, flow control statements underlying conditional statement
principles and input/output statements were used to run the program intuitively. The
programmers assigned different variables and different variables. For instance, we have set pg,
mg, and fg were used to print “Enter finals grade”. And for the “sem_grade” in using flow
control conditional statements, “if float” and “elif float” were used to set a rule that if the sem
grade may be less than, greater than, or equal to 70, there will be a printed phrase of “your grade
is” including an emoticon. After running the program, there will be cells for inputting each grade
to get the rate of the semestral grade.

22
IV. Conclusion
This laboratory activity taught new learnings to the authors when it comes to Python
Fundamentals and these lessons were completed in a virtual classroom setting by using
emulation and following the instructor. The instructor first introduced Google Colab and GitHub
as applications for formatting different Coding Python methods. In addition, different techniques
were used to learn the meanings behind the variations of codes. By coding, students learned
variables and data types, operations, arithmetic, assignment operations, comparators, logical,
input and output, and looping statements where while and for are included, and flow control in
conditional statements and Functions.
The different techniques discussed in the laboratory activity are done by using Google
Colab for Python. The laboratory activity showed that[12345]Python scripts are extremely useful
and can serve as both a substitute and an addition to spreadsheets. The authors also discovered
the advantages of using Google Colab for Python is that it is possible to calculate over 100000
rows of cells without breaking your spreadsheet, and it is possible to incorporate cutting-edge
machine learning techniques for data and text analysis. If there are advantages there will also be
disadvantages:[123456] Poor Memory Efficiency, Slow Speed, Database Access, Weak in
Mobile Computing and its Runtime Errors.
Overall, this laboratory activity taught the authors not only what to type in Google Colab,
but also how to recognize the implications of each format on how to use Google Colab for
Python, as well as what can be done to prevent things that may affect the efficiency and speed of
creating codes. It also explained how different codes work on their own and in conjunction with
others.

23
References
[12345] M.V.D. Reym. “7 Advantages of Using Google Colab for Python,” Medium, 2020.
Retrieve from: https://python.plainenglish.io/7-advantages-of-using-google-colab-for-python-82ac5166fd4b

[123456] Webandcrafts“Advantages and Disadvantages of of Python - A Complete Guide


Retrieve from: https://webandcrafts.com/blog/advantages-and-disadvantages-of-python/

[123457] “Return & Void Statements in Python.” 2020, July 21


Retrieved from https://study.com/academy/lesson/return-void-statements-in-python.html.

24

You might also like