Aufgabe 4 & Aufgabe 5

master
Timo Wenz 2022-05-03 21:47:07 +02:00
parent 0d9c274bb7
commit b787c6d204
2 changed files with 21 additions and 1 deletions

View File

@ -0,0 +1,5 @@
n = int(input("Enter n:"))
s = 0.0
for i in range (1, n + 1):
s = s + 1.0 / (i * i)
print(s)

View File

@ -2,3 +2,18 @@ import numpy as np
a=np.array([[3,0,-2,11],[0,0,9,0],[0,7,0,0],[0,0,0,-3]]) a=np.array([[3,0,-2,11],[0,0,9,0],[0,7,0,0],[0,0,0,-3]])
print(a) print(a)
my_list = [[], [], [], []]
MAX_LENGTH = 4
for i in range(0, MAX_LENGTH):
for j in range(0, MAX_LENGTH):
n = int(input("Enter n:"))
my_list[i].insert(j, n)
print(my_list)
print()
for i, row in enumerate(my_list):
for j, item in enumerate(row):
print(f'a[{i}] [{j}] = {item} ', end=' ')
print()