The Escuela

← Automata in Python: all 2 parts

Computer science ยท Free practice

Automata in Python, Part 1: A DFA as a Python Dictionary

Watch the lesson by Dr. J. Ubaldo Quevedo, then practice as many times as you want: every New button gives you a new machine or string.

1. Watch

  • A DFA has states, an alphabet, a start state, accepting states (double circles) and a transition for every state and symbol.
  • In Python, store it as a dictionary: "start_s": "7", "accept": ["1","7"].
  • Each arrow becomes one entry of "delta": the key is "state,symbol" and the value is the next state, as in "7,6": "5".

2. Try it yourself

Practice as many times as you want. Every New button builds a new machine or string. It's free, and you don't need an account.

Correct so far: 0