Automata Practical Exam - DFA and Turing Machine
Project description
Automata Practical Exam – Section 5
Student Info
- Section Number: 5
- Tasks Solved:
- DFA that accepts binary strings containing the substring
101 - Turing Machine that recognizes binary numbers divisible by 3
- DFA that accepts binary strings containing the substring
Project Structure
automata_practical_exam_<4549>/
│
├── automata/ # Python package root
│ ├── __init__.py # makes this a package
│ ├── dfa.py # DFA implementation
│ └── turing_machine.py # Turing Machine implementation
│
├── tests/ # Unit tests
│ ├── test_dfa.py
│ └── test_turing_machine.py
│
├── README.md # this file
└── setup.py # package metadata
-------------------------------------------------
>>>Installation
# from project root
pip install -e .
Installs the package in “editable” mode so you can modify code and see changes immediately.
>>>Usage
1. Import and run the DFA
from automata.dfa import DFA
dfa = DFA()
print(dfa.accepts("010101")) # True
print(dfa.accepts("0100")) # False
------------------------------------------------
2. Import and run the Turing Machine
from automata.turing_machine import TuringMachine
tm = TuringMachine("110") # binary 6
print(tm.run()) # True (6 divisible by 3)
tm2 = TuringMachine("101") # binary 5
print(tm2.run()) # False (5 not divisible by 3)
------------------------------------------------
>>>>>Running Tests
pip install pytest
pytest tests/
Or run individual test files:
python -m pytest tests/test_dfa.py
python -m pytest tests/test_turing_machine.py
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file automata_practical_mohamedaz-0.1.tar.gz.
File metadata
- Download URL: automata_practical_mohamedaz-0.1.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92e1350b14335e99d2b4bbf32999472875223a53d23620db95ddac38b982eb03
|
|
| MD5 |
3712788a9aea21b9d0f601e6298f7ba4
|
|
| BLAKE2b-256 |
289727fc34a83decc3758d90d609403da4e83f559ee3b9a4d0edb6f2595c7050
|
File details
Details for the file automata_practical_mohamedaz-0.1-py3-none-any.whl.
File metadata
- Download URL: automata_practical_mohamedaz-0.1-py3-none-any.whl
- Upload date:
- Size: 3.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6329732e4651c2010df4ee41123b78f97f207303de52c2a59c09647cf9088cb0
|
|
| MD5 |
e4a228a59bb3bf944a14221680f815cb
|
|
| BLAKE2b-256 |
5ddb21b55e0e05ca3e603823eb97592b8e79016be0a0f658fdf60749e316b6bf
|