Skip to content
Tutorials Center
My learning

Topics

Lesson 46 of 50 · Projects and Practice

Project 2: Build an Italian Verb Conjugator in Python

Build an Italian verb conjugator in Python: present, passato prossimo, imperfetto, future and conditional for regular and irregular verbs, then test it.

You have now met five tenses and many irregular verbs. In this project you will turn that knowledge into a program: an Italian verb conjugator written in Python that produces the present tense, the passato prossimo, the imperfetto, the future and the conditional. Building it forces you to state every rule precisely, and testing it shows where your own understanding is shaky. It is one of the best ways to learn a verb system.

You do not need advanced Python. The program uses dictionaries, lists and a few functions. Everything runs in the page, so you can edit the code and watch the output change.

A conjugation machine: the infinitive parlare goes in, a rule engine with stem, endings and exceptions in the middle, and a table of tenses comes out
The conjugator: classify the verb, look for exceptions, then apply stem plus ending rules.

What you will learn

  • How to represent Italian verb rules as data (endings and exceptions).
  • How to separate regular rules from irregular exceptions.
  • How to build and test five tenses in one program.
  • How to extend the program with new verbs.

Key terms

Coniugare: to conjugate, to give all the forms of a verb.

Radice (stem): the part of the infinitive left when you remove -are, -ere, -ire.

Desinenza (ending): the part added to the stem to show person and tense.

Eccezione (exception): an irregular form that the general rule does not produce.

The design

A good conjugator follows the same thinking you use yourself:

  1. Look for an exception first. Is this verb in our table of irregular forms? If yes, use that form.
  2. Otherwise use the rule. Find the verb group (-are, -ere, -ire), take the stem and add the endings for the tense.
  3. For compound tenses, choose the helper. Avere or essere, then add the participle.

We keep the data in dictionaries: rules (endings per group and tense), exceptions (full forms for irregular verbs in the present, and stems for the future and imperfetto), and participles.

Step 1: the regular endings

For each tense we store six endings (io, tu, lui/lei, noi, voi, loro) for each group:

Tense -are -ere -ire
Present o, i, a, iamo, ate, ano o, i, e, iamo, ete, ono o, i, e, iamo, ite, ono
Imperfetto avo, avi, ava, avamo, avate, avano evo, evi, eva, evamo, evate, evano ivo, ivi, iva, ivamo, ivate, ivano
Future erò, erai, erà, eremo, erete, eranno erò, erai, erà, eremo, erete, eranno irò, irai, irà, iremo, irete, iranno
Conditional erei, eresti, erebbe, eremmo, ereste, erebbero same irei, iresti, irebbe, iremmo, ireste, irebbero

The future and conditional of -are verbs use -er- (parlerò) because the a changes to e, and -ere verbs keep their e (venderò).

Step 2: the exceptions

Irregular present tenses must be stored in full. We also store irregular future stems (sar-, avr-, andr-) and irregular imperfetto forms (ero, facevo). The participles are stored for irregular verbs, with a rule for the regular ones (-ato, -uto, -ito). Finally we remember which verbs use essere as their helper.

Step 3: the full program

Read the code slowly, and run it. Then change the list at the bottom to conjugate your own verbs.

Python Italian verb conjugator

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Step 4: test it

Programmers test their code, and a conjugator is easy to test because you already know many correct answers. The second TryIt runs a set of assertions: lines that stop the program with an error if a form is wrong. It uses a trimmed copy of the functions above so that this block runs on its own.

Python Test the conjugator with assertions

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

If one fails, the rule or the data is wrong, and you now know where to look. Add tests for the irregular present forms as well.

Step 5: ideas for extension

  • More verbs. Add dare, bere, rimanere, scegliere to the dictionaries.
  • Reflexive verbs. Add a flag that inserts mi, ti, si, ci, vi, si and uses essere in the past.
  • The subjunctive. Store the present subjunctive stems from the previous chapter.
  • A quiz mode. Pick a random verb, tense and person and ask the learner to type the answer.
  • Better error messages. For a verb that is not recognized, print a friendly note instead of failing.

A word of warning: a program like this models regular patterns well, but Italian has many exceptions beyond our tables (for example -care and -gare spelling changes in the future, or irregular participles of many verbs). Always check a dictionary or a trusted grammar for verbs you are unsure about.

Reading the code line by line

The program has three layers. The data layer at the top stores the endings and exceptions in dictionaries. The rule layer (the functions present, imperfetto, future and conditional) first checks the exception dictionary and then falls back on the regular rule. The display layer (show) prints the five tenses.

Look closely at fut_stem_of. It takes the infinitive, drops the final -e (parlare becomes parlar), and for -are verbs replaces the final ar by er (parler). For -ere and -ire verbs the stem remains (vender, dormir). The function passato selects the helper from the uses_essere set and, for essere verbs, changes the last letter of the participle to -o, -a, -i or -e. One subtle point is the index test i > 2: persons 4, 5 and 6 (noi, voi, loro) are plural.

If you want to debug a form, print the intermediate values: the stem, the ending and the helper. A small print(stem, ending) often shows the problem immediately. When you add a new irregular verb, add it in the data layer rather than inside a function: this keeps the rules short and the exceptions visible, and it is how professional language software is organized as well.

Common misconceptions

"A program that conjugates is the same as understanding grammar." It models the rules you give it; your own understanding comes from using forms in sentences.

"All verbs ending in -ire behave the same." Verbs like finire add -isc- in the present (finisco), others like dormire do not.

"If the tests pass, the program is perfect." Tests only cover the cases you wrote. Add more as you meet new verbs.

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. In the program, why is the dictionary of exceptions checked first?

    If a verb is irregular, using the regular rule would give a wrong form, so exceptions come first.
  2. 2. What does the future stem of 'parlare' become in the program?

    -are verbs change a to e in the future and conditional stem: parler-.
  3. 3. Which helper does the program use for 'andare' in the passato prossimo?

    Andare is in the uses_essere set, so it forms sono andato, sei andato...
  4. 4. What is the purpose of an assertion test?

    Assertions compare the program's output with a known correct answer and flag differences.

Summary

  • A conjugator checks exceptions first, then applies stem-and-ending rules.
  • Store rules and exceptions as data (dictionaries) and keep code short.
  • Compound tenses need the right helper and an agreeing participle.
  • Test with known answers, extend with new verbs, and always verify unusual verbs in a dictionary.

Next: Practice set: mixed exercises