From b787c6d204050acce30ec74952741500e8a2af7a Mon Sep 17 00:00:00 2001 From: Timo Wenz <2025014@stud.hs-mannheim.de> Date: Tue, 3 May 2022 21:47:07 +0200 Subject: [PATCH] Aufgabe 4 & Aufgabe 5 --- python/s1/s1_a4.py | 5 +++++ python/s1/s1_a51.py | 17 ++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 python/s1/s1_a4.py diff --git a/python/s1/s1_a4.py b/python/s1/s1_a4.py new file mode 100644 index 0000000..3f38621 --- /dev/null +++ b/python/s1/s1_a4.py @@ -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) \ No newline at end of file diff --git a/python/s1/s1_a51.py b/python/s1/s1_a51.py index f2422cb..5c9fc9f 100644 --- a/python/s1/s1_a51.py +++ b/python/s1/s1_a51.py @@ -1,4 +1,19 @@ import numpy as np a=np.array([[3,0,-2,11],[0,0,9,0],[0,7,0,0],[0,0,0,-3]]) -print(a) \ No newline at end of file +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() \ No newline at end of file