Skip to content

Commit 6deba32

Browse files
Add files via upload
Estruturas de dados: Matrizes.ipynb: Introdução a matrizes (arrays) e suas operações. Set (Conjuntos).ipynb: Exploração de conjuntos e suas características únicas. Dicionários.ipynb: Apresentação de dicionários e como utilizá-los para armazenar pares chave-valor. Tuplas.ipynb: Introdução a tuplas, estruturas de dados imutáveis. Listas.ipynb: Tutorial sobre listas, a estrutura de dados mais flexível do Python. Programação: Funções.ipynb: Criação e utilização de funções para organizar e reutilizar código. For - Para.ipynb: Iteração sobre elementos usando o loop for. While - Enquanto.ipynb: Repetição de ações com o loop while enquanto uma condição for verdadeira. Função If - Se.ipynb: Tomada de decisões no código com a estrutura condicional if. Fundamentos: Primeiros Passos.ipynb: Notebook introdutório com os conceitos básicos da linguagem Python.
1 parent ff1781d commit 6deba32

10 files changed

+15358
-0
lines changed

CONDITIONALS.ipynb

+857
Large diffs are not rendered by default.

Dictionaries.ipynb

+2,799
Large diffs are not rendered by default.

Do-While.ipynb

+1,719
Large diffs are not rendered by default.

FIRST-STEPS.ipynb

+1,459
Large diffs are not rendered by default.

For.ipynb

+1,706
Large diffs are not rendered by default.

Functions.ipynb

+1,975
Large diffs are not rendered by default.

Lists.ipynb

+2,538
Large diffs are not rendered by default.

MATRIX.ipynb

+147
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 13,
6+
"id": "b0452902",
7+
"metadata": {},
8+
"outputs": [
9+
{
10+
"name": "stdout",
11+
"output_type": "stream",
12+
"text": [
13+
"[[10, 11, 12], [13, 14, 15], [16, 17, 18]]\n",
14+
"\n",
15+
"Printing Matrix A\n",
16+
"Matrix A:\n",
17+
"\n",
18+
"10 11 12\n",
19+
"13 14 15\n",
20+
"16 17 18\n",
21+
"\n",
22+
"Matrix B:\n",
23+
"1 2 3\n",
24+
"4 5 6\n",
25+
"7 8 9 \n",
26+
"\n",
27+
"Matrix D:\n",
28+
"0 0 0 \n",
29+
"0 0 0\n",
30+
"0 0 0\n",
31+
"\n",
32+
"Subtraction of matrices A and B\n",
33+
"[9, 9, 9]\n",
34+
"[9, 9, 9]\n",
35+
"[9, 9, 9]\n",
36+
"\n",
37+
"Sum of matrices A and B:\n",
38+
"11 13 15\n",
39+
"17 19 21\n",
40+
"23 25 27\n",
41+
"\n",
42+
"The sum of the diagonal elements of matrix A is: 42\n"
43+
]
44+
}
45+
],
46+
"source": [
47+
"\"\"\"\n",
48+
"Matrices:\n",
49+
"\n",
50+
"Initializing the two matrices and the result matrix\n",
51+
" Using nested for loops to subtract matching elements\n",
52+
"\"\"\"\n",
53+
"\n",
54+
"#Practical Example: Subtraction of 3x3 Matrices in Python\n",
55+
"\n",
56+
"#Matrix subtraction, like addition, is an element operation\n",
57+
"#a element. To subtract two matrices, they must have the same dimensions. \n",
58+
"#The result is a new matrix with the same dimension, where each element is the difference\n",
59+
"#of the corresponding elements of the two original matrices.\n",
60+
"\n",
61+
"#Initializing the two matrices and the result matrix:\n",
62+
"\n",
63+
"# Initialize matrix A with predefined values\n",
64+
"A = [[10, 11, 12], [13, 14, 15], [16, 17, 18]]\n",
65+
"print(A)\n",
66+
"\n",
67+
"# Print a line break followed by a title for matrix A\n",
68+
"print(\"\\nPrinting Matrix A\")\n",
69+
"\n",
70+
"# Print the title for array A\n",
71+
"print(\"Matrix A:\\n\")\n",
72+
"\n",
73+
"# Start a loop to traverse the rows of the matrix\n",
74+
"for line in range(3): \n",
75+
"\n",
76+
" # Starts an internal loop to traverse the columns of the matrix\n",
77+
" for column in range(3): \n",
78+
"\n",
79+
" # Print the value of the current element of the array followed by two spaces, without breaking the line\n",
80+
" print(f\"{A[line][column]}\", end=\" \") \n",
81+
"\n",
82+
" # Print a line break after printing all the elements of a complete line of the matrix\n",
83+
" print() \n",
84+
"\n",
85+
"\n",
86+
"# Initialize matrix B with predefined values\n",
87+
"B = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]\n",
88+
"\n",
89+
"# Print a line break followed by a title for matrix B\n",
90+
"print(\"\\nMatrix B:\")\n",
91+
"\n",
92+
"# Start a loop to traverse the rows of the matrix\n",
93+
"for line in range(3): \n",
94+
"\n",
95+
" # Starts an internal loop to traverse the columns of the matrix\n",
96+
" for column in range(3): \n",
97+
"\n",
98+
" # Print the value of the current element of the array followed by two spaces, without breaking the line\n",
99+
" print(f\"{B[row][column]}\", end=\" \") \n",
100+
"\n",
101+
" # Print a line break after printing all the elements of a complete line of the matrix\n",
102+
" print() \n",
103+
"\n",
104+
"\n",
105+
"# Initialize matrix D with all elements being zero\n",
106+
"D = [\n",
107+
" [0, 0, 0], \n",
108+
" [0, 0, 0], \n",
109+
" [0, 0, 0]\n",
110+
"]\n",
111+
"\n",
112+
"# Print the title for array D\n",
113+
"print(\"\\nMatrix D:\")\n",
114+
"\n",
115+
"# Start a loop to traverse the rows of the matrix\n",
116+
"for line in range(3):\n",
117+
"\n",
118+
" # Starts an internal loop to traverse the columns of the matrix\n",
119+
" for column in range(3):\n",
120+
"\n",
121+
" # Print the value of the current element of the array followed by two spaces, without breaking the line\n",
122+
" print(f\"{D[row][column]}\", end=\" \")\n",
123+
"\n",
124+
" # Print a line break after printing all the elements of a complete line of the matrix\n",
125+
"print()\n",
126+
"\n",
127+
"\n",
128+
"# Subtraction of matrices A and B\n",
129+
"\n",
130+
"print(\"\\nSubtraction of matrices A and B\")\n",
131+
"# Start a loop to traverse the rows of the matrix\n",
132+
"for line in range(3): \n",
133+
"\n",
134+
" # Starts an internal loop to traverse the columns of the matrix\n",
135+
" for column in range(3): \n",
136+
"\n",
137+
" # Subtracts the value in matrix B from the corresponding value in matrix A and stores the result in matrix D\n",
138+
" D[line][column] = A[line][column] - B[line][column]\n",
139+
"\n",
140+
"# Start a loop to go through each row of matrix D\n",
141+
"for line in D:\n",
142+
"\n",
143+
" # Print the current row of matrix D\n",
144+
" print(line)\n",
145+
"\n",
146+
"\n",
147+
"print()

0 commit comments

Comments
 (0)