0% found this document useful (0 votes)
6 views10 pages

Soft Copy TOC

Uploaded by

ayushbhoir321
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views10 pages

Soft Copy TOC

Uploaded by

ayushbhoir321
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Practical No 1

Aim : Write a program for tokenization of given input.

Input:

Output:
Practical No 2
Aim: Write a program for generating regular expressions for regular
grammer.
Input:
import re
s = 'A computer science portal'
match = re.search(r'portal', s)
if match:
print('Start Index:', match.start())
print('End Index:', match.end())
else:
print('No match found')

Output:
Practical No. 3
Aim: Write a program for generating derivation sequence/ language
for the given sequence of productions.
Input:

Output:
Practical No 4
Aim: Design a Program for creating machine that accepts three
consecutive one.
Input:

Output:
Practical No. : 05
Aim : Design a Program for creating machine that accepts the string
always ending with 101.
Input:

def q1(s, i) :

print("q1->", end="");

if (i == len(s)) :
print("NO");
return;

if (s[i] == '0') :
q1(s, i + 1);
else :
q3(s, i + 1);

def q2(s, i) :

print("q2->", end = "");


if (i == len(s)) :
print("NO");
return;

if (s[i] == '0') :
q4(s, i + 1);
else :
q2(s, i + 1);
def q3(s, i) :

print("q3->", end = "");


if (i == len(s)) :
print("YES");
return;

if (s[i] == '0') :
q4(s, i + 1);
else :
q2(s, i + 1);

def q4(s, i) :

print("q4->", end = "");


if (i == len(s)) :
print("YES");
return;

if (s[i] == '0') :
q1(s, i + 1);
else :
q3(s, i + 1);

def q0( s, i) :
print("q0->", end = "");
if (i == len(s)) :
print("NO");
return;
if (s[i] == '0') :
q1(s, i + 1);
else :
q2(s, i + 1);
# Driver Code
if __name__ == "__main__" :
s = "010101";

print("State transitions are", end = " ");


q0(s, 0);

Output:

Practical No 6
Aim: Design a program for accepting decimal number divisible by 2.
Input:

Output:

Practical No. : 07
Aim : Design a program for creating a machine which accepts string having
equal no. of 1’s and 0’s.

Practical No. : 08
Aim : Design a program for creating a machine which count number of 1’s
and 0’s in a given string.
Input:

Output:

You might also like