Question

Write a function program in python to implement/simulate a finite automaton that accepts (only):Odd length binary...

Write a function program in python to implement/simulate a finite automaton that accepts
(only):Odd length binary numbers // 0000001, 101, 11111, etc.

the program must be based on the finite automatic theory. cannot use string

0 0
Add a comment Improve this question Transcribed image text
Answer #1
def accept_odd_length_strings():
    state = 0
    while True:
        ch = input("Enter a character(enter to exit): ")
        if ch == '':
            break
        if state == 1:
            state = 0
        else:
            state = 1
    if state == 1:
        print("String is accepted")
    else:
        print("String is not accepted")


accept_odd_length_strings()
Add a comment
Know the answer?
Add Answer to:
Write a function program in python to implement/simulate a finite automaton that accepts (only):Odd length binary...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT