Level 9.5 Python Aufgabenbuch

Задание 1

Gegeben eine beliebige zweidimensionale Liste:

python[
  [11, 12, 13, 14, 15],
  [21, 22, 23, 24, 25],
  [31, 32, 33, 34, 35],
  [41, 42, 43, 44, 45],
  [51, 52, 53, 54, 55],
]

Setzen Sie die Elemente der Hauptdiagonale auf Null:

python[
  [ 0, 12, 13, 14, 15],
  [21,  0, 23, 24, 25],
  [31, 32,  0, 34, 35],
  [41, 42, 43,  0, 45],
  [51, 52, 53, 54,  0],
]
Задание 2

Erstellen Sie eine Funktion, die die korrekte Form des Substantivs nach einer Zahl setzt. So soll die Funktion funktionieren:

pythonfunc(1, 'Apfel', 'Äpfel', 'Äpfel'); // gibt '1 Apfel' aus
func(2, 'Apfel', 'Äpfel', 'Äpfel'); // gibt '2 Äpfel' aus
func(3, 'Apfel', 'Äpfel', 'Äpfel'); // gibt '3 Äpfel' aus
func(4, 'Apfel', 'Äpfel', 'Äpfel'); // gibt '4 Äpfel' aus
func(5, 'Apfel', 'Äpfel', 'Äpfel'); // gibt '5 Äpfel' aus

Hier ist ein Beispiel für zweistellige Zahlen:

pythonfunc(11, 'Apfel', 'Äpfel', 'Äpfel'); // gibt '11 Äpfel' aus
func(12, 'Apfel', 'Äpfel', 'Äpfel'); // gibt '12 Äpfel' aus
func(21, 'Apfel', 'Äpfel', 'Äpfel'); // gibt '21 Apfel' aus
func(23, 'Apfel', 'Äpfel', 'Äpfel'); // gibt '23 Äpfel' aus

Unsere Funktion soll für Zahlen beliebiger Länge funktionieren:

pythonfunc(1223421, 'Apfel', 'Äpfel', 'Äpfel'); // gibt '1223421 Apfel' aus