English – irregular verbs

The English language has some peculiarities and make the English language unnecessarily complicated. One of these peculiarities are the irregular verbs. Why they exist at all is beyond my knowledge. The formation of tenses in English is basically simple, but consists of 12(!) Tenses.
All of them are used to express different time references and types of action. Here are the main tenses and their formation in English:

  • Simple Present:
    Formation: Subject + verb (infinitive) + -s/-es (singular for the 3rd person) For example:
  • I play tennis. (I play tennis.)
  • He plays tennis. (He plays tennis.)
  • Present Continuous:
    Formation: Subject + to be (in the appropriate form) + verb (gerund) Example:
  • I am playing tennis. (I’m playing tennis right now.)
  • She is playing tennis. (She’s playing tennis.)
  1. Present Perfect:
    Formation: Subject + have/has + verb (past participle) For example:
  • I have played tennis. (I played tennis.)
  • We have seen that movie. (We’ve seen the movie.)
  1. Simple Past:
    Education: Subject + Verb (Past Simple) Example:
  • I played tennis. (I played tennis.)
  • She watched a movie. (She was watching a movie.)
  1. Past Continuous:
    Formation: Subject + what/were + verb (gerund) Example:
  • I was playing tennis. (I was playing tennis.)
  • They were studying for the exam. (They were studying for the exam.)
  1. Past Perfect:
    Formation: Subject + had + verb (past participle) Example:
  • I had played tennis. (I had been playing tennis.)
  • She had already left when I arrived. (She had already left when I arrived.)
  1. Simple Future:
    Education: Subject + will + verb (infinitive) Example:
  • I will play tennis. (I’m going to play tennis.)
  • They will arrive tomorrow. (They will arrive tomorrow.)
  1. Future Continuous:
    Education: Subject + will be + verb (gerund) Example:
  • I will be playing tennis. (I’m going to play tennis right now.)
  • She will be studying for the exam. (She will study for the exam.)
  1. Future Perfect:
    Formation: Subject + will have + verb (past participle) Example:
  • I will have played tennis. (I will have played tennis.)
  • They will have finished the project by next week. (They will have completed the project by next week.)

These nine tenses are the basic tenses in English. There are also other tenses, such as the Present Perfect Continuous, the Past Perfect Continuous, and the Future Perfect Continuous, which express more complex temporal references.

So actually not so difficult. Funny, however, are these irregular words, such as go – the past is went – they don’t even have a letter in common. What helps us is. that we learn them by heart. We are now building a program for this.

There are 283 irregular verbs. Sounds a lot – it is. Typing them all into the source code in an array is not only tedious, but also makes the code a bit unreadable. So we decide to outsource the verbs. We will use a simple text file for this. In this text file we write all the verbs we want to learn, line by line, the individual tenses separated by „,“.

This is what our file looks like:

be, am/are, was/were, been
begin, begins, began, begun
break, breaks, broke, broken
bring, brings, brought, brought
build, builds, built, built

We now have to read this file somehow into our Python program. Thankfully, this is very easy to do in Python. There is the open command for this. The open command is our key to the files. He needs two parameters. The first parameter is the file name, the second is the mode that indicates what we want to do with the file. There are four different modes

„r“ – Read – default value. Opens a file for reading, returns an error if the file does not exist.
„a“ – Append – Opens a file for attaching, creates the file if it does not exist
„w“ – Write – Opens a file for writing, creates the file if it does not exist
„x“ – Create – Generates the specified file, returns an error if the file already exists.
To open our file, just use the following command:
Since „r“ is the default value, we can refrain from specifying it, but for the readability of the code it is always good to specify the „r“ in such a case.
The open function returns a file object, which we can then work with subsequently.
If we run the following lines of code:

f = open('irregular_verbs.txt', 'r')

we output the whole file.
We still have a small problem. If the file does not exist, then the open function throws an error and our program would simply abort. To prevent this, there is the os.path.exists function in the os library. With this function it is possible to check if a data or directory exists. exists outputs either true or false.

But now it starts. The first thing we do is build a function to load the file and package it into an array

def load_irregular_verbs(file_path):
    irregular_verbs = []
    with open(file_path, 'r') as file:
        for line in file:
            verb, present_s, past_s, past_participle = line.strip().split(', ')
                'verb': verb,
                'present_singular': present_s,
                'present_plural': 'are' if present_s == 'am' else present_s,
                'past_singular': past_s,
                'past_plural': 'were' if past_s == 'was' else past_s,
                'past_participle': past_participle
    return irregular_verbs

Let’s take a closer look at this feature.
First, we create an empty list called Irreguläre_Verben = []‘. Subsequently, we will fill them with the individual verbs from the file.

Next, we open the file of our means
with open(file_path, ‚r‘) as file:
in reading mode (‚r‘). What is important here is the preceding ‚with‘ statement. This causes the file object to be closed properly after the indented code block (suite) is finished, even if an exception is thrown during execution.
At night we have „for line in file:“. This loop iterates through each line of the open file. The variable contains the contents of line each row.

verb, present_s, past_s, past_participle = line.strip().split(', ') takes each line in the file, removes all leading and trailing spaces (strip()), and then splits them into four parts separated by commas and spaces (‚, ‚).

irregular_verbs.append({ … })erstellt unser Wörterbuch mit dem Verb und seinen verschiedenen Formen (Singular/Plural für Präsens und Präteritum sowie Partizip der Vergangenheit) und fügt es an die Listeirregular_verbs‘ using append.

Finally, we return all the verbs that have been read in.

The next function is to build our trainer

def irregular_verbs_trainer(irregular_verbs):
    score = 0
    num_Frage = 5

    for _ in range(num_Frage):
        random_verb = choose_random_verb(irregular_verbs)

        verb = random_verb['verb']

        tense = random.choice(list(random_verb.keys()))
        correct_form = random_verb[tense]

        user_input = input(f"What is the {tense.replace('_',' ')} form of '{verb}'? ")

        if user_input == correct_form:
            score +=1
            print(f"Wrong. The correct answer is '{correct_form}'.")


    print(f"Quiz abgeschlossen! Du hast {score}/{num_Frage} richtig! Gut gemacht!")

It’s actually the same as in fractions, except that we choose a verb from the list.

You can download the whole source code as a Visual Studio project at gpiwonka/IrregularVerbs: A small trainer for learning the English Irregular Verbs (github.com).
Have fun!