Latin declension

Latin declension is an important linguistic concept in Latin grammar that describes the inflection, or inflection, of nouns, adjectives, and pronouns. There are five main declensions in Latin, each of which has its own endings and patterns. Here is a general explanation of the five declensions:
Declension (masculine nouns): This declension includes mainly masculine nouns, but also some feminine ones. The nominative ending is „-us“ (masculine) or „-a“ (feminine). Example: „dominus“ (lord), „puella“ (girl). Singular:
Nominative: dominus, puella
Genitive: domini, puellae
Dative: domino, puellae
Accusative: dominum, puellam
Ablative: domino, puella Plural:
Nominative: domini, puellae
Genitive: dominorum, puellarum
Dative: dominis, puellis
Accusative: dominos, puellas
Ablative: dominis, puellis
Declension (feminine nouns): The nominative ending of this declension is „-a“ (feminine). Example: „pink“ (rose). Singular:
Nominative: pink
Genitive: rosae
Dative: rosae
Accusative: pink
Ablative: pink plural:
Nominative: rosae
Genitive: rosarum
Dative: rosis
Accusative: rosas
Ablative: rosis
Declension (masculine and feminine nouns): The nominative ending of this declension is „-is“ (masculine and feminine). Example: „civis“ (citizen), „virtus“ (virtue). Singular:
Nominative: civis, virtus
Genitive: civis, virtutis
Dative: civi, virtuti
Accusative: civem, virtutem
Ablative: cive, virtute Plural:
Nominative: cives, virtutes
Genitive: civium, virtutum
Dative: civibus, virtutibus
Accusative: cives, virtutes
Ablative: civibus, virtutibus
Declension (masculine nouns): The nominative ending of this declension is „-us“. For example, „portus“ (port). Singular:
Nominative: portus
Genitive: portus
Dative: portui
Accusative: portum
Ablative: portu Plural:
Nominative: portus
Genitive: portuum
Dative: portibus
Accusative: portus
Ablative: portibus
Declension (masculine and feminine nouns): The nominative ending of this declension is „-es“. Example: „rexs“ (king), „res“ (thing). Singular:
Nominative: rex, res
Genitive: regis, rei
Dative: regi, rei
Accusative: regem, rem
Ablative: rege, re Plural:
Nominative: reges, res
Genitive: regum, rerum
Dative: regibus, rebus
Accusative: reges, res
Ablative: regibus, rebus
Please note that in Latin there are also neutras that have a different declension, as well as special cases and exceptions in the declension of some words. Declension is important for determining the grammatical function of a word in a sentence and using the correct form.
With this knowledge, we can’t make the world a better place, but we can improve our knowledge of the Latin language and our programming skills at the same time.
With the knowledge we have acquired so far, we can create the program in no time
import random

Function to load the declensions from the external file

def lade_deklinationen_aus_datei(dateipfad):
    deklinationen = {}
    with open(dateipfad, "r", encoding="utf-8") as datei:
        for zeile in datei:
            teile = zeile.strip().split()
            if len(teile) == 5:
                nominativ, genitiv, dativ, akkusativ, ablativ = teile
                deklinationen[nominativ] = {
                    "genitiv": genitiv,
                    "dativ": dativ,
                    "akkusativ": akkusativ,
                    "ablativ": ablativ
                }
    return deklinationen

Latin nouns and their declensions

declensions = lade_deklinationen_aus_datei(„declensions.txt“)

def lateinische_deklination_ueben():
# Choose a random noun
noun = random.choice(list(declensions.keys()))

# Hole die korrekten Deklinationen für das Substantiv
korrekte_deklinationen = deklinationen[substantiv]

# Zeige das ausgewählte Substantiv an und fordere die Eingabe der Deklinationen
print(f"Deklination von: {substantiv}")
antworten = {}
for fall in ["genitiv", "dativ", "akkusativ", "ablativ"]:
    antworten[fall] = input(f"Gib die {fall} Form ein: ")

# Überprüfe die eingegebenen Deklinationen
richtig = True
for fall, antwort in antworten.items():
    if antwort != korrekte_deklinationen[fall]:
        richtig = False
        print(f"Falsch! Die richtige {fall} Form ist: {korrekte_deklinationen[fall]}")

if richtig:
    print("Richtig! Gut gemacht!")
if name == "main":
while True:
      lateinische_deklination_ueben()
      weitermachen = input("Willst du noch eine? (Ja/Nein): ").lower()
      if weitermachen != "ja":
         Break

The source code can be found under gpiwonka/LatinDeclension (github.com ).