Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

BES 103– Computer Fundamentals and Programming

Lab Activity 4: Arrays

LEARNING OUTCOMES: At the end of this lesson, you are


expected to:
1. Execute a Python program that can generate Arrays.
2. Analyze how nested For loop is used in creating multi-dimensional
arrays or matrices.
3. Create a Python program that will allow the user to input m x n
matrix.

TIME FRAME: 1 Week

INTRODUCTION:
In this Lesson, you will explore to run that can generate Arrays and
Matrices examples in Python using Nested For loops. After completing this
lesson, you will be more confident in creating your own Python program
involving arrays and matrices.
Enjoy exploring!

1. Run the Pycharm.


2. Select and Click ‘New’ in the File tab them choose Python file and name it
using your family
SURNAME_PythonLab4_LabAct9.py

3. In it, encode the following codes shown in Figure 4.1 on your PyCharm
editor.
BES 103– Computer Fundamentals and Programming

4. Once done, right click on any part of the editor then select and click Run.
5. In the Run tool window seen below the editor, you will be asked to enter
any number. Once done inputting, press “Enter” to continue.

6. Screenshot the Editor window as well as the Run tool window.

Figure 4.1 Array Program

7. The images of the two windows must be documented and must include
captions. Also, draw a conclusion about the activity. The output of this
Activity as well as the Analysis section seen below must be saved in one
document.

2|Page BES 103


BES 103– Computer Fundamentals and Programming

From the items in Activity 4, answer the following questions:

1. Explain what the nested for loop shown below did with the 9 numbers
you entered:

Answer:_____________________________________________________
___________________________________________________________
___________________________________________________________
___________________________________________________________
_______________________________________________________

2. Explain what the second nested for loop shown below did with first
nested for loop.

Answer:_____________________________________________________
___________________________________________________________
___________________________________________________________
___________________________________________________________
_______________________________________________________.
3. What is the function of the line code shown below of this program?

Explain._____________________________________________________
___________________________________________________________
___________________________________________________________
_______________________________________________________.

3|Page BES 103


BES 103– Computer Fundamentals and Programming

4. Compare the output of the line codes shown in the above items 2 & 3.
to the line codes shown below.

Explain._____________________________________________________
___________________________________________________________
___________________________________________________.

5. What needs to be modified for the program to generate a 2x2 matrix?


Explain._____________________________________________________
___________________________________________________________
_____________________________________________________.

4|Page BES 103

You might also like