0% found this document useful (0 votes)
31 views

APP Holy Book - Advanced Programming Practice

Uploaded by

ramsrini533
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

APP Holy Book - Advanced Programming Practice

Uploaded by

ramsrini533
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 159

lOMoARcPSD|23351831

APP Holy Book - Advanced Programming Practice

Advanced Programming Practice (SRM Institute of Science and Technology)

Scan to open on Studocu

Studocu is not sponsored or endorsed by any college or university


Downloaded by Sudharsanan Radhakrishnan ([email protected])
lOMoARcPSD|23351831

A.

SECTION-A

1 1 AStructured Programming element which execute a list of statements in order.

A. Repetition

B. Selection

C. Sequence

D. Iteration

ANSWER: C

1 2 A Structured Programming element which allows an uncontrolled structure that allows the
flow of execution to jump to a different part of the program

A. Repetition

B. Selection

C. Sequence

D. Branching

ANSWER: D

1 3 A method of planning programs that avoids the branching category of control structures.

A. imperative programming

B. declarative programming

C. structured programming

D. . functional programming

ANSWER: C

1 4 Which of the following doesn9t belong to the structured Programming Category

A. Algol 68

B. Ada 95

C. pascal

D. Ada 83.

ANSWER: B

1 5 Procedural language contains systematic order of

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

A. statements

B. objects

C. classes

D. operations

ANSWER: A

1 6 In procedural language, programmer creates the list of

A. data

B. instructions

C. paradigm

D. operations

ANSWER: B

1 7 A type of computer programming language that specifies a series of well-structured steps and
procedures within its programming context to compose a program is known as

A. Procedural language

B. Structural language

C. Assembly language

D. Machine language

ANSWER: A

1 8 fruits = ["apple", "banana", "cherry"]

for x in fruits:

if x == "banana":

break

print(x)

predict the output of the above prog

A. banana

B. apple

C. apple banana. cherry

D. rror

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

ANSWER: B

1 9 Each module in procedural language is composed of one or more

A. modules

B. sub programs

C. paradigm

D. operations

ANSWER: B

1 10 Structured Programming also known as

A. Procedural Programming

B. Object Oriented Programming

C. Progressive Programming

D. Machine Language Programming

ANSWER: B

1 11 In Procedural Programming, programs are divided into different procedures also known as

A. Functions, routines or subroutines

B. Usefulness, routines or subroutines

C. Functions, structured or unstructured

D. Routines, structured or unstructured

ANSWER: A

1 12 Each module in procedural language is composed of one or more

A. modules

B. sub programs

C. paradigm

D. operations

ANSWER: B

1 13 In Object Oriented Programming Instantiation is called as

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

A. Deleting an instance of class

B. Modifying an instance of class

C. Copying an instance of class

D. Creating an instance of class

ANSWER: D

1 14 Name the methods that begin and end with two underscore characters

A. Special methods

B. In-built methods

C. User-defined methods

D. Additional methods

ANSWER: A

1 15 Which of the following statements is most accurate for the declaration y = Square()?

A. . y contains an int value

B. . y contains an object of the Square type C. y contains a reference to a

Square object

D. You can assign an int value to y.

ANSWER: C

1 16 What programming paradigm - uses a series of instructions that tell the computer what to do
with the input in order to solve the problem?

A. Procedure

B. Object Oriented

C. Declarative D. Functional

ANSWER: A

1 17 Regular expressions and SQL belong to which paradigm?

A. Procedure

B. Object Oriented

C. Declarative D. Functional

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

ANSWER: C

1 18 Which paradigm dictates HOW the program solves a problem?

A. Procedure

B. Object Oriented

C. Declarative D. Imperative

ANSWER: D

2 19 What function will add Kevin to the end of the array names?

names = [8Mike9, 8James9, 8Derrick9]

A. names.add(8Kevin9)

B. names.append(8Kevin9)

C. names(colors,

D. names.arrayadd(

ANSWER: B

2 20 What is the right way to print out 8Python code9?

A. print("Python code")

B. print " Python code"

C. printPython code

D. print("Python code");

ANSWER: A

2 21 What will this code print? The date in this scenario is 2020-05-03 11:12:30.

time = datetime.now()

print time.year A.

2020-05-03

B. 0.47256944444

C. 2020-05-03 11:20:30

D. 2020

ANSWER: D

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

2 22 What is the output of the given python code?

t1==ADVANCED= t2==AVNCES=

intersect(t1,t2)

A. [8A9,9V9,9N9,9D9]

B. [8D9,9N9,9D9]

C. [8A9,9V9,9C9,9E9]

D. [8A9,9V9,9N9,9C9,9E9]

ANSWER: D

2 23 Check whether the following syntax is correct or not.Find the suitable answer.

def add(**att)

A. Partially correct

B. Partially wrong

C. It matches and collects remaining keyword arguments in a dictionary

D. Fully wrong

ANSWER: C

2 24 What will be the outcome if you execute the code "print 1/2"?

A. 1/2

B. 0

C. 0.5

D. 2/4

ANSWER: C

2 25 Find the equivalent statement of the following

delattr(b,9ball9) A.

del b.ball

B. ball.b del

C. attrdel(b.ball)

D. b.ball(delattr)

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

ANSWER: A

2 26 Select which is false about Python.

1.A function is not a code block.

2.Python always return a value.

3.Python doesn9t support nested function.

4.Functions can be reused in a program.

A. Both 1 & 2

B. Both 1 & 3

C. 4 only

D. 1 only

ANSWER: B

2 27 In logic programming, the common approach is to apply the methods of _________ and

___________

A. Unification, resolution

B. Resolution, Reduction

C. Deduction, Heap Building

D. Propositions, Unification

ANSWER: A

2 28 Building blocks of logic programming are _________ and __________

A. Rules to move forward, problem statement

B. facts to work, constraints which allow us to make conclusions

C. True statements, Goal to achieve

D. Constraints for decision making, ways to achieve the goal

ANSWER: B

2 29 Identify the series which is not a logic operator sequence.

A. c, ∪, +

B. ∪, +,¬

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

C. &&, ∥

D. £,>,<

ANSWER: D

2 30 ∀ x, y : if father(x, y) or mother(x, y) then parent(x, y).

Based on the fact given, which of the following is false?

A. parent(x, y) ¢ mother(x, y)

B. parent(x, y) ¢ father(x, y)

C. parent(x, y) ¢ mother(x, y) && father(x,y)

D. parent(x, y) ¢ mother(x, y) || father(x,y)

ANSWER: C

2 31 Which of the following is incorrect about first class functions in python? A.

A function is an instance of the Object type.

B. Functions can be stored in a variable

C. Functions cannot be stored in data structures such as hash tables

D. Functions can be passed as a parameter to another function.

ANSWER: C

2 32 Which of the following is a pure function in Python? A.

def add (sum,b)

return sum+b

sum++

B. a=10

b=10

def add (a,b):

return a+b+2

a=a+10

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

C. int s=0 def add():

return 10+s

s++

D. def add():

a=10

b=20

return a+b

a=a+10

ANSWER: D

2 33 def all_add(x):

def add(y):

return x + y

return add

add_25 = all_add(25) print(add_25(10))

Identify the output of the above code:

A. Exception thrown

B. 35

C. 25

D. add(10)

ANSWER: B

2 34 Which of the following is true about Recursive functions in Python?

A. Recursive makes the code complex

B. Recursive calls are expensive as they take up a lot of memory and time

C. Recursive calls are easy to debug

D. Sequence generation is easier with nested functions in relation with recursive functions

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

ANSWER: B

2 35 What is the output of the following code?

fromsympy import * x =

Symbol('x') y =

Symbol('y') q= 2x +3 y +4

x -2 y print("value of

q:",str(q))

A. 6x+y

B. 6x-y

C. Syntax Error D. 6x+5y

ANSWER: C

2 36 What is the output of the following segment according to the given Statements: fromsympy

import tan

x = Symbol('x') ans1 = diff(tan(x),

x) print("derivative of tan(x): ",

ans1)

A. –cos(x)

B. Cos(x)

C. tan(x)-1

D. tan(x)**2 + 1

ANSWER: D

3 37 Which of the following is the right representation of the given differentiation? d3y/dx3

A. diff(y,x**3)

B. diff(y,x,x,x)

C. diff(f(x),y)

D. diff(y,3x)

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

ANSWER: B

3 38 Find the Fourier series for the following

∫ sinxdx

A. fourierseries(sinx,x,0,pi)

B. fourier_series(sin*x,x,pi,0)

C. fourier_series(sin(x),(x,0,pi))

D. fourier_series(sin(x),x,0,pi)

ANSWER: C

3 39 What is the output of the following Python code for the given statements?

from sympy import * x =

Symbol('x') y = Symbol('y')

ans=simplify((4*x + x * y) /2*x)

print(ans)

A. y + 1

B. x**2*(y + 4)/2

C. y+1

D. x+1

ANSWER: B

3 40 What is the output of the following Python code for the given statements?

fromsympy import *

x = Symbol('x') val = Matrix([[1,

2], [2, 1]]).col(1) print(val)

A. Matrix([[2],[1]])

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

B. Matrix([[2],[2]])

C. Matrix([[1],[1]])

D. Matrix([[-2],[1]])

ANSWER: A

3 41 Which of the following is the right representation for the given integration? ∫

ex dx

A. integration(e*x,dx)

B. integrate(e*x,x)

C. integrate(exp(x),x)

D. integrate(x*exp(e),x)

ANSWER: C

3 42 What is the output of the following Python code for the given statements?

from sympy import *

x = Symbol('x') y = Symbol('y')

res=simplify((8*x + x * 2*y) /8*x*y)

print(res)

A. y + 1

B. x**2*(y + 4)/2

C. x**2*y*(y + 4)/4

D. x+1

ANSWER: C

3 43 What is the output of the following Python code for the given statements?

fromsympy import *

x = Symbol('x') y =

Symbol('y')

integrate(x**2, (x,1,1))

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

A. 0

B. 1

C. -1

D. -2

ANSWER: A

3 44 A function has dependent type if the ______of a function's result depends on the _______ of
its Argument

A. value and type

B. type and value

C. type and type

D. value and value

ANSWER: B

3 45 Dependent type paradigm used to encode logic's quantifiers like _____and _______

A. for one, there may exists

B. for all, there always

C. for all, there exists

D. for specific, there exists

ANSWER: C

3 46 In python the dependent type programming demo one of the components is not used. Find
the odd man out

A. Arrays

B. Union

C. Overload

D. Literal

ANSWER: A

3 47 If the several activates can execute at the same time without being depent to each other, it
may be known as

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

A. Processing

B. Parallel processing

C. Serial Processing

D. Multi-Tasking

ANSWER: B

3 48 A thread is also known as

A. Process

B. Heavy weight process

C. Light weight process

D. A computer program

ANSWER: C

3 49 If multiple threads can access a resource simultaneously, this term is known as

A. Multiprogramming

B. Multitasking

C. Concurrency

D. Threads

ANSWER: C

3 50 Which two module does python offers to implement threads in python programming.

A. <Thread> , <Threads>

B. <Multi_thread>, <pthread>

C. <threadpool>, <threadclass>

D. <thread>, <threading>

ANSWER: D

3 51 Which method returns the name of a thread

A. getName()

B. setName()

C. putName()

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

D. fetchName()

ANSWER: A

3 52 What is the difference between threading.Lock and threading.Rlock

A. Lock is owned by a thread while RLock is owned by many

B. Lock and RLock both primitives are owned by a single thread

C. Lock and RLock both primitives are owned by many

D. Lock is owned by none while RLock is owned by many

ANSWER: D

3 53 Race conditions are &

A. Testing which thread completes first

B. Two threads incorrectly accessing a shared resource

C. Something you should add to your code

D. No way related to threads

ANSWER: B

3 54 For Synchronizing thread, which syntax is correct to release lock

A. threadLock.release()

B. release()

C. thread_id.release()

D. th_release()

ANSWER: A

4 55 Procedural language contains systematic order of

A. statements

B. objects

C. classes

D. operations

ANSWER: A

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

4 56 In procedural language, programmer creates the list of

A. data

B. instructions

C. paradigm

D. operations

ANSWER: B

4 57 A type of computer programming language that specifies a series of well-structured steps and
procedures within its programming context to compose a program is known as

A. Procedural language

B. Structural language

C. Assembly language

D. Machine language

ANSWER: A

4 58 fruits = ["apple", "banana", "cherry"] for

x in fruits:

if x == "banana":

break

print(x)

predict the output of the above prog

A. banana

B. apple

C. apple banana. cherry

D. rror

ANSWER: B

4 59 Each module in procedural language is composed of one or more

A. modules

B. sub programs

C. paradigm

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

D. operations

ANSWER: B

4 60 Structured Programming also known as

A. Procedural Programming

B. Object Oriented Programming

C. Progressive Programming

D. Machine Language Programming

ANSWER: B

4 61 In Procedural Programming, programs are divided into different procedures also known as

A. Functions, routines or subroutines

B. Usefulness, routines or subroutines

C. Functions, structured or unstructured

D. Routines, structured or unstructured

ANSWER: A

4 62 Which of the following is the advantage of declarative languages over imperative languages?

A. Can use abstract data type

B. Easy to verify the properties of the program

C. Is more efficient

D. Can be implemented by an interpreter or compiler

ANSWER: B

4 63 What is not true about Declarative programming?

A. focus is on what needs to be done rather how it should be done

B. style of building programs that expresses logic of computation without talking about its control
flow

C. declare the result we want rather how it has be produced

D. builds programs using implementation logic

ANSWER: D

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

4 64 What is false regarding imperative languages?

A. work by modifying program state

B. code executes too slowly for optimal results on complex data science applications

C. focus on what and not how

D. executes step by step commands

ANSWER: C

4 65 With respect of lamba function predict the output for the following

a = lambda x : x * x a(4) A. 4

B. 16

C. ERROR

D. NO OUTPUT

ANSWER: B

4 66 Predict the output of the following code

disp = lambda str: print('Output: ' + str)

disp("Hello World!")

A. Output: Hello World!

B. Hello World

C. Hello World!

D. ERROR

ANSWER: A

4 67 Predict the output of the following code

hof = lambda x, f1: x + f1(x)

hof(3, lambda x: x * x)

A. 3

B. 9

C. 12

D. ERROIR

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

ANSWER: C

4 68 Which is the right syntax to join two lists in Python?

A. Listoflist={listA},{ListB}

B. Listoflist=[listA,ListB]

C. Listoflist=[list+ListB]

D. Listoflist=[listA]+[ListB]

ANSWER: B

4 69 Which among the following is not true regarding Tuples?

A. To access values in tuple, use the square brackets along with the index

B. Removing individual tuple elements is not possible

C. the tuples cannot be changed once created

D. tup2 = [1, 2, 3, 4, 5 ] creates a tuple 8tup29 with 5 elements

ANSWER: D

4 70 Identify the true statement about a Dictionary?

A. dictionary is an ordered collection

B. It cannot be changed once created

C. The items can be accessed using keys in square brackets

D. It can be initialized using keys and values inside square brackets

ANSWER: C

4 71 Which is the right syntax for copying a dictionary?

A. mydict = thisdict.copyTo()

B. mydict = thisdict.copy()

C. mydict = new dict(thisdict)

D. dict2=dict1

ANSWER: B

4 72 Which among the following is not a part of Abstract Data Types interface?

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

A. Constructors

B. Mutators

C. Iterators

D. Destructors

ANSWER: D

5 73 What is the output printed of the below code snippets? Assume appropriate imports and
previous steps are done. tpl = srvr_sock.accept() print(tpl[1][0])

A. Socket object

B. Server IP and port

C. Client IP and port

D. Client IP

ANSWER: D

5 74 Which method is used to receive messages at clients if the protocol used is TCP.

A. )sock_object.recv()

B. sock_object.recvfrom()

C. sock_object.append()

D. sock_object.connect(

ANSWER: A

5 75 If the protocol adapted is UDP, to send a message to client which method is used?

A. c.send()

B. c.sendto()

C. c.sent()

D. c.sentto()

ANSWER: B

5 76 What does <socket.gethostbyname('www.google.com')= does?

A. Translates hostname 'www.google.com'to ip address

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

B. Returns a string containing hostname of 'www.google.com'

C. Establishes connection with google

D. Accepts the connection from google

ANSWER: A

5 77 <c, a= s.accept()=. What will be the value of <a= variable?

A. Client address

B. Server address

C. host name

D. IPV4 address

ANSWER: A

5 78 Constructor that can be used for creating a datagram socket that binds to a given Port
Number is?

A. Datagram Socket(int port)

B. Datagram Socket()

C. Datagram Socket(int port, Int Address address)

D. Datagram Socket(int address)

ANSWER: A

5 79 Which of the following function decides what code to run when there are a specific event
occurs, which are used to select which event handler to use for the event when there is specific
event occurred.

A. Inline Functions

B. Nested Functions

C. Trigger Functions

D. Friend Functions

ANSWER: C

5 80 Name the Widget, which provides the range of values to the user, out of which, the user can
select the one. A. Entry()

B. Canvas()

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

C. Scale()

D. Spinbox()

ANSWER: D

5 81 Which one of the following is not a Widget?

A. Input()

B. Canvas()

C. Scale()

D. Spinbox()

ANSWER: A

5 82 Name the parameter, which is used to set the color shown in the focus highlight.

A. focus

B. bg

C. bd

D. highlightcolor

ANSWER: D

5 83 Inorder to run our GUI application which method on the main window should be executed?

A. root.loop()

B. root. mainloop()

C. root.main()

D. root()

ANSWER: B

5 84 What is the syntax for setting the dimension of the window as 8350x2009?

A. window.geometry('350x200')

B. window.grid('350x200')

C. window.pack('350x200')

D. window.fill('350x200')

ANSWER: A

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

5 85 How many reference variables and objects are there for the given Python code?

class hello:

print("Inside class")

hello() hello() hello()

obj=hello() A. 3 and

B. 4 and 1

C. 1 and 4

D. 1 and 3

ANSWER: C

5 86 class stud:

def __init__(self, name, age):

self.name = name

self.age = age

What is the correct syntax for instantiating the above stud class?

A. stud.__init__("anu", 3)

B. stud()

C. stud(<anu=,3)

D. stud.create(<anu=,3)

ANSWER: C

5 87 Which is the correct syntax to check whether an object <ob= is an instance of class C or not?

A. ob.isinstance(C)

B. C.isinstance(ob)

C. isinstance(ob, C)

D. isinstance(C, ob)

ANSWER: C

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

5 88 How the statement <Class B:= should be modified so that <Class B inherits Class A= in python.

A. class B(A):

B. class A(B):

C. class B extends A

D. class B::A

ANSWER: A

5 89 In the Python code given below, What type of inheritance is used?

Class b1:

------------

Class b2:

---------

Class c(b1,b2):

-------

A. Multi-level inheritance

B. Multiple inheritance

C. Hierarchical inheritance

D. Single-level inheritance

ANSWER: B

5 90 Inorder to access the methods of parent class which is overridden in a child class that inherits
it, What method is used

A. super()

B. override()

C. this()

D. init()

ANSWER: A

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

SECTION - B

1 1 Predict the output of the following code

i=5

def f(arg=i):

print(arg) i =

6 f()

A. 5

B. 6

C. ERROR D. 5.6

ANSWER: A

1 2 Which of the following syntax is wrong with respect to IF Statement in python A.

if condition:

B. if

condition:

statement1

statement2

C. if

(condition):

statement elif

(condition):

statement

else:

statement

D. if

(condition):

Statement; elif

(condition):

statement;

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

ANSWER: D

1 3 Predict the output of the following code

i=1

while True: if

i%3 == 0: break

print(i)

i+=1

A. 1 2

B. 1 2 3

C. ERROR D. 1

ANSWER: C

1 4 ef func1(a=2,b=3):

print(a,' ',b)

func1() func1(3)

A. 2 32

B. 2 33

C. 2 2

3 3

D. 2 3

ANSWER: B

1 5 Consider the following table structure

CREATE TABLE COMPANY

(ID INT PRIMARY KEY NOT NULL,

NAME TEXT NOT NULL,

AGE INT NOT NULL,

ADDRESS CHAR(50),

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

SALARY INT;)

Dem

A. a. conn.execute('''CREATE TABLE COMPANY

(ID INT PRIMARY KEY NOT NULL,

NAME TEXT NOT NULL,

AGE INT NOT NULL,

ADDRESS CHAR(50),

SALARY INT;''');

B. conn.executequery('''CREATE TABLE COMPANY

(ID INT PRIMARY KEY NOT NULL,

NAME TEXT NOT NULL,

AGE INT NOT NULL,

ADDRESS CHAR(50),

SALARY INT;''');

C. conn.exec('''CREATE TABLE COMPANY

(ID INT PRIMARY KEY NOT NULL,

NAME TEXT NOT NULL,

AGE INT NOT NULL,

ADDRESS CHAR(50),

SALARY INT;''');

D. conn.execquery('''CREATE TABLE COMPANY

(ID INT PRIMARY KEY NOT NULL,

NAME TEXT NOT NULL,

AGE INT NOT NULL,

ADDRESS CHAR(50),

SALARY INT;''');

ANSWER:

1 6 How protected Members are declared inside a python code

A. prefix with underscore

B. declare protected scope

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

C. prefix the name with double underscore

D. preficx and sufix with a underscore

ANSWER: A

1 7 What paradig the code follows:


import random as r a =
r.randrange(0,2,1) c = input("Enter
Number : ") b = int(c) if a==b:

print("Draw") elif a==0 a

A. Procedure

B. Structure

C. Declarative D. Functional

ANSWER: B

1 8 What is the output of the following Python program?

num1 = 5 if

num1 >= 91:

num2 = 3

else:

if num1 < 6:

num2 = 4

else:

num2 = 2 x = num2

* num1 + 1 print

(x,x%7)Marks 1

A. 21 0

B. 21 3

C. 21 21

D. 3 21

ANSWER: A

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

1 9 what gets printed?

a = range(5) b

= range(10)

print(zip(a,b))

A. 1 2 3 4 5

B. 5 10

C. [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4)]

D. 0, 0, 1, 1, 2, 2, 3, 3, 4, 4

ANSWER: A

1 10 What sequence of numbers is printed?

values = [1, 2, 1, 3]

nums = set(values) def

checkit(num): if num in

nums: return True else:

return False for i in

filter(checkit, values):

print i

A. 1 2 1

B. 1 2 1 3

C.

1 2 13 1 2 1 3

D. Error

ANSWER: B

1 11 What gets printed?

def myfunc(x, y, z, a):

print x + y nums = [1, 2,

3, 4]

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

myfunc(*nums)

A. 3

B. 1

C. 4

D. 5

ANSWER: A

1 12 How private Members are declared inside a python code

A. prefix with underscore

B. declare protected scope

C. prefix the name with double underscore

D. preficx and sufix with a underscore

ANSWER: C

2 13 _______ is required for connecting to a server

A. socket.AF_INET

B. socket.DGRAM

C. protocol D. IP

ANSWER: D

2 14 _____ represents the address in connectionless network

A. port,host

B. port

C. host

D. host,port

ANSWER: D

2 15 Preferring an connection oriented network which method is used at the client side for
message passing

A. sock_object.recv()

B. sock_object.recvfrom()

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

C. sock_object.sent()

D. sock_object.sendto()

ANSWER: A

2 16 _____ is passed so as to bind the socket to the address

A. SOCK_STREAM

B. SOCK_DGRAM

C. AF_INET

D. protocol

ANSWER: C

2 17 Consider the following output: What is the syntax for creating the menu <File= in the above
window?

A. m= Menubar(root)

filemenu = Menubar(m, tearoff=0)

m.add_cascade(label="File", menu=filemenu)

B. m= Menu(root)

filemenu = Menu(m)

m.add_cascade(label="File")

C. m= Menu(root)

filemenu = Menu(m, tearoff=0)

m.add_cascade(label="File", menu=filemenu)

D. m= Menubar(root)

filemenu = Menubar(m)

m.add_cascade(label="File")

ANSWER: C

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

2 18 Consider the following output.#variable <window refers to the main window created using tk=

What is the syntax for creating the radiobutton with caption <C=?

A. R1 = Radiobutton(window, caption="C", variable=radio, value=1)

B. R1 = Radiobutton(top, text="C", variable=radio, value=1)

C. R1 = Radiobutton(window, text="C", variable=radio, value=1)

D. R1 = Radiobutton(top, caption="C", variable=radio, value=1)

ANSWER: C

2 19 Consider the following output. What is the correct syntax for creating field <Submit= in the
above window?

A. parent = Tk() submit = Button(parent, command =

"Submit").grid(row = 0, column = 0)

B. parent = Tk() submit = Button(parent, text =

"Submit").grid(row = 0, column = 0)

C. parent = Tk() submit = Button(parent, text =

"Submit").grid(row = 2, column = 0)

D. parent = Tk() submit = Button(parent, command=

"Submit")

ANSWER: C

2 20 Consider the following output. What is the syntax for changing the title of the window to
<Programming Language=? A. window = Tk() window(label== Programming Language=)

B. window = Tk() window.title("Programming Language")

C. title(<Programming Language=)

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

D. window(<Programming Language=)

ANSWER: B

2 21 Consider the following code

class first: a = 10 b

= 20

def add(self):

sum = self.a + self.b

print(sum) ob = first()

print(first.a) print(ob.b)

ob.add()

What will be the output of the above code?

A. 0 20 30

B. 10 20 30

C. 10 20 0

D. error

ANSWER: B

2 22 What will be the output of the following Python code?

class student: def __init__(self, name, age):

self.name = name self.age = age

def myfunc(self): print("Student

name is " + self.name) s1 = student("XXX",

36) s1.age A. xxx 20 hi

20

Student name is xxx

B. xxx

20

xxx

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

20

Student name is hi

C. xxx

20

hi

20

Student name is hi

D. xxx

36

hi

36

Student name is hi

ANSWER: C

2 23 Which one is incorrect under constructor in object oriented programming

A. The default function that is executed when the class is initiated

B. Instantiate the objects

C. Assign values to those class variables

D. A function that executes when the class is created

ANSWER: D

2 24 The idea of imperative programming paradigm imitates

A. Graphical User Interface programming

B. Symbolic programming

C. Automata programming

D. Object oriented programming

ANSWER: D

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

3 25 Which of the following is false regarding dependent types?

A. They allow us to write programs and know they are correct before running them.

B. They allow us to write programs and know they are correct only after running them.

C. You can specify types that can check the value of your variables at compile time.

D. Its definition depends on a value.

ANSWER: B

3 26 Which of the following is false about quantifiers? A.

Notation ∀ is used for Universal quantifier.

B. Notation ∃is used for Existential quantifier.

C. <All men drink tea= is an example of Universal Quantifier

D. <All men drink coffee= is an example of Existential Quantifier.

ANSWER: D

3 27 Which of the following is correct for predicate <All men drink coffee=?

A. x men(x) → (x, coffee)


B. drink (x, coffee)→ x men(x)
C. x men(x) → drink (x, coffee)
D. men(x) → drink (x, coffee)

ANSWER: C

3 28 Let x be a variable which refers to Universe of Disclosure such as x1,x2....xn then, how to
represent this statement using quantifiers < All Man working in Industry=
A. x man(x) → work (x, Industry)
B. x man(x) → work(industry).
C. x man(x) → work (x, industry)
D. x man(x) → Industry(work)

ANSWER: B

3 29 How do you represent the statement <Every man respects his parent=?
A. x woman(x) → respects (x, parent)
B. x man(x) → respects (x, parent)

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

C. x man → respects (x, parent)


D. x man(x) → respects (parent).

ANSWER: B

3 30 Which of them is a correct way to start a new process in multiprocessing

A. spawn

B. fork

C. forkserver

D. all a, b &c are correct way to start a new process

ANSWER: D

3 31 Which processing mode will give highest throughput in ideal condition( consider that all
processes are independent to each other )

A. Serial Processing

B. Parallel Processing

C. Concurrent Processing

D. Time sharing

ANSWER: B

3 32 If <wait for graph= for a set of processes contains a cycle, So it means

A. There is no chance for a deadlock to occur

B. The system is in a safe state.

C. There is a chance for a deadlock to occur

D. The system is not in a safe state

ANSWER: C

3 33 Consider the below given code and guess what value will x return in this code

>>> from multiprocessing import Pool

>>> p = Pool(5) >>>

def f(x):

>>> return x**x

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

A. square of given value

B. Cube of given value

C. return the value of parameter

D. return the value of xx

ANSWER: D

3 34 Which is the correct syntax to include pool class into code

A. from multiprocessing import pool

B. include pool

C. import pool_class

D. include poolclass

ANSWER: A

3 35 >>>p=pool(5). Consider this syntax and choose correct option

A. a pool of three worker process

B. a pool of five worker process

C. a pool of five main process

D. a pool of one main and four worker process

ANSWER: B

3 36 Consider each line of code as an option in given code and find the wrong syntax to calculate
the cube of a number

A. from multiprocessing import process

B. def cube(x):

C. for x in numbers :

D. print (8%s is = %s 8 % (x,x*3))

ANSWER: D

4 37 Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after list1.pop(1)?

A. [3, 4, 5, 20, 5, 25, 1, 3]

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

B. [1,3,3,4,5,5,20,25]

C. [3,5,20,5,25,1,3]

D. [1,3,4,5,20,5,25]

ANSWER: C

4 38 What is the output of the following Python code ?

defmyfunc(text,num):

while (num>0):

print(text) num

= num -1

myfunc(8Hello9,4)

A. HelloHelloHelloHello

B. Infinite loop

C. No error

D. Statement missing

ANSWER: B

4 39 What is the output of the following program ? import re sentence

= 'deers are fast' regex = re.compile('(?P<animal>w+) (?P<verb>w+)

(?P<adjective>w+)') matched = re.search(regex, sentence)

print(matched.groupdict())

A. {8animal9:9deers9,9verb9:9are9,9adjective9:9fast9}

B. {8deers9,9are9,9fast9}

C. 9deers are fast9 D. 9are9

ANSWER: A

4 40 Find the missing code of given python snippet def

sq(a):

return (a* *2) def

cu(a):

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

rerurn (a* *3) for n in range(5)

value =map(lambda a: a(n),fcs)

print value A.

fcs=[sq,cu,1]

B. fcs[cu,sq]

C. fcs=[sq,cu]

D. fcs[1,sq,cu]

ANSWER: C

4 41 def multiply (num):

num_2=[]

for I in num:

num_2.append(n*2)

return num_2

num= [1,2,3,4]

num_1=multiply(num)

print(num)

print(num_1)

Is the above function a pure function? Why

A. No, because it modifies the state of the variable num_1

B. Yes, because it produces no change in variable num

C. Yes, because it produces the multiplied list.

D. Yes, because it alters the values of the num list.

ANSWER: B

4 42 write a command to update SALARY to 25000.00 where ID = 1

A. conn.executequery("UPDATE COMPANY set SALARY = 25000.00 where ID = 1")

B. conn.execquery("UPDATE COMPANY set SALARY = 25000.00 where ID = 1")

C. conn.exec("UPDATE COMPANY set SALARY = 25000.00 where ID = 1")

D. conn.execute("UPDATE COMPANY set SALARY = 25000.00 where ID = 1")

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

ANSWER: D

4 43 Demonstrate the equivalent lambda function for the function cube to compute cube of a
number

A. (lambda x: x*x*x )(5)

B. (lambda x*x*x )(5)

C. g = lambda x*x*x (5)

D. g = lambda(x*x*x ) (5)

ANSWER: A

4 44 With respect to functions answer the following

1. Predict the output of the following code

def sum_args(*numbers):

return sum(numbers)

print (sum_args(23, 42, 21,22))

A. 23

B. 108

C. NO OUTPUT D. ERROR

ANSWER: B

4 45 Illustrate the syntax to replace all <x= with <r= for the given string s and print

A. print (replace('r', 'x'))

B. print (S.replace('r', 'x', all))

C. print (S.replace('r', 'x'))

D. print (S.replace('r', 'x', 1))

ANSWER: C

4 46 With respect to looping statements in python answer the following

1. i=1

while True:

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

print(i)

i=i+1

if(i > 3):

break

predict the output of the above program

A. 1 2 3

B. 1

C. 2

D. 3

ANSWER: A

4 47 Predict the output of the following code

fruits = ["apple", "banana", "cherry"] for x in

fruits:

if x == "banana":

continue

print(x)

predict the output of the above program

A. banana

B. apple cherry

C. apple banana cherry

D. apple banana

ANSWER: B

4 48 3. Predict the output of the following Map, Reduce and Filter

a.x = [12, 34]

print(len(list(map(len, x))))

A. 2

B. 1

C. 0

D. ERROR

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

ANSWER: D

5 49 Output of the following program is:

importsympy as sym

x, y, z = symbols('x y z') given_exp

= x + y + z exps =

sym.expand(given_exp**2)

diffre = diff(exps, x) print("The Differentiation

is: ",format(diffre))

A. The Differentiation is: 2**x + 2**y +2**z

B. The Differentiation is: 2*x + 2*y +2*z

C. The Differentiation is:2*(x*y*z)

D. The Differentiation is:2*(x+y+z)

ANSWER: A

5 50 Output of the following program is:

importsympy as sym exp

= sym.Rational(3, 12)

sym.solveset(y ** 4 -1, y)

A. {−1,1,i,-i}

B. {−1,1,−i,i}

C. {−i,i,−1,1}

D. {−1,i,−i,1}

ANSWER: B

5 51 What is the output of the following Python code for the given statements?

fromsympy import *

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

x = Symbol('x') y = Symbol('y')

solution=solve((x+4*y-2,-2*x+6*y-15),(x,y))

solution[x], solution[y]

A. 24/7,19/4

B. -24/7, 19/4

C. 24/4,19/4

D. 24/4,-19/4

ANSWER: B

5 52 What is the output of the following Python code for the given statements?

fromsympy import * x =

Symbol('x') y = Symbol('y')

integrate(exp(-x**2)*erf(x),x)

A.

B. C.

D.

ANSWER: A

5 53 Consider the following code

class first: a = 10 b

= 20

def add(self):

sum = self.a + self.b

print(sum) ob = first()

print(first.a) print(ob.b)

ob.add()

What will be the output of the above code?

A. 0 20 30

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

B. 10 20 30

C. 10 20 0 D. error

ANSWER: B

5 54 What will be the output of the following Python code?

class student: def __init__(self, name, age):

self.name = name self.age = age

def myfunc(self): print("Student

name is " + self.name) s1 = student("XXX",

36) s1.age A. xxx 20 hi

20

Student name is xxx

B. xxx

20

xxx

20

Student name is hi

C. xxx

20

hi

20

Student name is hi

D. xxx

36

hi

36

Student name is hi

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

ANSWER: C

5 55 Which one is incorrect under constructor in object oriented programming

A. The default function that is executed when the class is initiated

B. Instantiate the objects

C. Assign values to those class variables

D. A function that executes when the class is created

ANSWER: D

5 56 The idea of imperative programming paradigm imitates

A. Graphical User Interface programming

B. Symbolic programming

C. Automata programming

D. Object oriented programming

ANSWER: D

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

SECTION – C

1 1 If you have some functions with many parameters and you want to specify only some of

them, then you can give values for such parameters by naming them is

A. Reference Arguments

B. Keyword Arguments

C. Default Arguments

D. Var-Args

ANSWER : B

1 2 What is the Output of the code:

a=5b=

c ='hello'

d ='Hello'

print ( a is b ) print

( c is not d ) A.

true false

B. false false

C. true true

D. false true

ANSWER : C

1 3 class A:

def __init__(self):

print('Initializing: class A')

class B(A): def

__init__(self):

___Insert Code __ print('Initializing: class B')

class C(B):

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

def __init__(self): insert

code -----

print('Initializing: class C')

A. A.__init__() B.__init____()

B. base.__init__() base.__init____()

C. parent.__init__() parent.__init____()

D. super().__init__() super().__init____()

ANSWER : D

1 4 Prime focus of the Paradigm is on functions and procedures that operate on data

A. Procedure

B. Structural

C. Decalrative

D. Object oriented

ANSWER : B

1 5 Prime Focus of the Paradigm is on the data that is being operated and not on the functions or
procedures

A. Procedure

B. Structural

C. Decalrative

D. Object oriented

ANSWER : D

1 6 Which paradigm offers the least amount of abstraction and is machine dependent?

A. Procedure

B. Structural

C. Decalrative

D. Lowlevel

ANSWER : D

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

2 7 The paradigm that pass messages between the end nodes

A. Symbolic programming

B. Automata programming

C. Object oriented programming

D. Network programming paradigm

ANSWER : D

2 8 After the intial setup has been established by the server and the client which are those
additional methods that can be used regardless of connection or connectionless with a half bit
transmission and involving twice the triplet clients awaiting for the server.

A.
Socket(),bind(),listen(3),accept(),write(),connect(),recv(1024),read(),send(),sendto(),recvfrom(1024)

B. Socket(),bind(),listen(6),accept(),write(),connect(),recv(512),read(),send(),sendto(),recvfrom(512)

C. listen(3),accept(),write(),connect(),recv(1024),read(),send(),sendto(),recvfrom(1024)

D. listen(6),accept(),write(),connect(),recv(512),read(),send(),sendto(),recvfrom(512) ANSWER : D

2 9 What would be the geometry manager for the output of

A. NButton = Button(frame, text = 'North', fg ='black')

NButton.pack( side = LEFT)

EButton = Button(frame, text = 'East', fg='black')

EButton.pack( side = LEFT )

SButton = Button(frame, text ='South', fg ='black')

SButton.pack( side = LEFT )

WButton =

B. NButton = Button(frame, text = 'North', fg ='black')

NButton.grid( row = 0,column=0)

EButton = Button(frame, text = 'East', fg='black')

EButton.grid( row = 1,column=1 )

SButton = Button(frame, text ='South', fg ='black')

SButton.grid( row=0,column=1

C. NButton = Button(frame, text = 'North', fg ='black')

NButton.grid( row = 1,column=0)

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

EButton = Button(frame, text = 'East', fg='black')

EButton.grid( row = 0,column=1 )

SButton = Button(frame, text ='South', fg ='black')

SButton.grid( row=1,column=1

D. NButton = Button(frame, text = 'North', fg ='black')

NButton.place(E)

EButton = Button(frame, text = 'East', fg='black')

EButton.place(N)

SButton = Button(frame, text ='South', fg ='black')

SButton.place(W)

WButton = Button(bottomframe, text ='West'

ANSWER : A

2 10 Methods that are compulsory to be defined while designing the user interface in python

A. tk(),mainloop()

B. tk(),title()

C. title(),mainloop()

D. title(),pack()

ANSWER : A

2 11 The concept of more than one forms when applied to the inherited concepts leads to

i)virtual class ii) method overloading iii) method overriding iv) abstract class

A. i,ii and iii

B. i,iii and iv

C. ii, iii and iv D. i,iii and iv

ANSWER : B

2 12 The class functions having more than one forms of a given class is termed to be

A. inheritance

B. overriding

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

C. overloading

D. encapsulation

ANSWER : C

3 13 Let P(x) be the predicate <x must take a discrete mathematics course= and let Q(x) be the
predicate <x is a computer science student=. Which of the following statements is correct for
<Everybody must take a discrete mathematics course or be a computer science student=?
A. x(Q(x) V P(x))
B. x(Q(x)) V x(P(x))
C. x(Q(x) || P(x))
D. x(Q(x) -> P(x))

ANSWER : A

3 14 What is the way to determine if a given function is dependant type?

A. Result is independent of the argument

B. Result depends upon the usage in the program

C. Result depends on the Value of its argument

D. Result depends on available resources

ANSWER : C

3 15 The given code will print the assigned id of a sub-process. Code is divided into small parts as
options a,b,c. choose the one which is having any wrong syntax. A. import multiprocessing
import time

B. class Process(multiprocessing.Process):

def __init__(self, id):

super(Process, self).__init__() self.id

= id

C. def run(self): time.sleep(1) print("I'm the process with id: {}".format(self.id))

D. Complete code is correct

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

ANSWER : D

3 16 The given code will print the cube of a number. Code is divided into small parts as options
a,b,c. choose the one which is having any wrong syntax.

A. from multiprocessing import Process

B. def cube(x):

for x in mynumbers:

print(%s is = %s' % (x, x**3))

C. if__name__ == '__main__': mynumbers = [3, 4, 5, 6, 7, 8] p = Process(target=cube, args=('x',))

p.start()

p.join()

D. code is correct

ANSWER : D

3 17 A system has 12 magnetic tape drives and 3 processes: P0, P1, and P2. Process P0 requires 10
tape drives, P1 requires 4 and P2 requires 9 tape drives. Currently allocated in process wise are 5,
2, 2 for processes 0, 1, 2 respectively.Which of the following sequence is a safe sequence?

A. P0, P1, P2

B. P1, P2, P0

C. P1, P0, P2

D. P2, P0, P1

ANSWER : C

3 18 The resource allocation graph is not applicable to a resource allocation system ____________

A. with multiple instances of each resource type

B. with a single instance of each resource type C. single & multiple

instances of each resource type

D. two instances of each resource type only.

ANSWER : A

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

4 19 A python program to find the fahrenheit and celsius for the following temperatures recorded
in the room using map/lamda function ,temp = (36.5, 37, 37.5,39) is given below

Celsius = [39.2, 36.5, 37.3, 37.8]

Fahrenheit = map(lambda x: (float(9)/5)*x + 32, Celsius) print

(Fahrenheit)

C = map(lambda x: (float(5)/9)*(x-32), Fahrenheit) print

(C) demonstrate using filter display only Celsius value is

even

A. result = filter(lambda x: x % 2 == 0, Celsius)

B. result = filter(lambda Celsius: Celsius % 2 == 0)

C. result = filter(lambda x: x % 2, Celsius)

D. result = filter(lambda Celsius: Celsius % 2)

ANSWER : A

4 20 Predict the output of the following code

def fu(x,y=None):

if y is None:

y=[]

y.append(x)

return(y)

fu([4])

fu([3])

A. [[4]] [[3]]

B. [[3]]

C. [[4]]

D. [[3], [4]]

ANSWER : B

4 21 . for x in range(1):

print(x)

else:

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

print("Finally finished!")

predict the output of the above program

A. 1

Finally finished

B. 0 1

C. 0

Finally finished

D. ERROR

ANSWER : C

4 22 What is the output of the following program?

filter_none edit

play_arrow

brightness_4 def

REVERSE(L):

L.reverse()

return(L)

def YKNJS(L):

List = list()

List.extend(REVERSE(L))

print(List)

L = [1, 3.1, 5.31, 7.531]

YKNJS(L)

A. [1, 3.1, 5.31, 7.531]

B. [7.531, 5.31, 3.1, 1]

C. IndexError

D. AttributeError: 8NoneType9 object has no attribute 8REVERSE9

ANSWER : B

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

4 23 Predict the value of L at the end of execution of the following program?

L = [2e-04, 'a', False, 87] T

= (6.22, 'boy', True, 554)

for i in range(len(L)):

if L[i]:

L[i] = L[i] + T[i]

else:

T[i] = L[i] + T[i]

Break

A. 6.222e-04, 8aboy9, True, 641]

B. [6.2202, 8aboy9, 1, 641]

C. [6.2202, 8aboy9, True, 87]

D. [6.2202, 8aboy9, False, 87]

ANSWER : D

4 24 How to fetch the data from Table COMPANY and print id, name, address, salary using python

A. cursor = conn.execute("SELECT id, name, address, salary from COMPANY") for row in cursor:

print "ID = ", row[0]

print "NAME = ", row[1]

print "ADDRESS = ", row[2]

print "SALARY = ", row[3], "\n"

B. cursor = conn.exec("SELECT id, name, address, salary from COMPANY") for

row in cursor:

print "ID = ", row[0]

print "NAME = ", row[1] print

"ADDRESS = ", row[2] print "SALARY

= ", row[3], "\n"

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

C. cursor = conn.select("SELECT id, name, address, salary from COMPANY")

for row in cursor:

print "ID = ", row[0]

print "NAME = ", row[1] print

"ADDRESS = ", row[2] print "SALARY

= ", row[3], "\n"

D. cursor = conn.executequery("SELECT id, name, address, salary from


COMPANY")

for row in cursor:

print "ID = ", row[0]

print "NAME = ", row[1] print

"ADDRESS = ", row[2] print "SALARY

= ", row[3], "\n"

ANSWER : A

5 25 What is the output of the given python code?

fromfunctools import reduce

defoddTimes(input):

print (reduce(lambda a, b: a ^ b, input))

if __name__ == "__main__":

input = [1, 2, 3, 2, 3, 1, 3]

oddTimes(input)

A. 1

B. 2

C. 3

D. Error

ANSWER : C

5 26 What is wrong with the below code and choose the correct answer from the given

options: app([1, 2, 3]) app() def app(n = []):

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

print n

1)Throw an error

2)The variable is n is local to the function <app>

3)Can9t be accessed outside

4)Nothing will be printed.

A. 1 & 2 is wrong

B. 3 alone is wrong

C. 4 alone is wrong

D. All the options are wrong.

ANSWER : D

5 27 Suppose the following details have been created using PyDatalog

If 50 is the pass mark, identify the right sequence of code that displays the marks of all students
who have passed.

A. pyDatalog.create_terms('pass9)

print(((mark[X]==Y) & (pass(Y)): pass(X)<= (X>50)))

B. pyDatalog.create_terms('pass9: X>50)

print((mark[X]) & (pass(Y))

C. pyDatalog.create_terms('pass9) pass(X)<=

(X>50) print((mark[X]==Y) & (pass(Y)))

D. pyDatalog.create_terms('pass9: X<=50)

print((mark[X]) & (pass(Y))

ANSWER : C

5 28 Given the following facts and rules, display the results using Queries in PyDatalog

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

Facts:

father ('Bill','Dany')

father ('Bill','Ellen') father

('Cathy','Furon') father

('Alan','Bob') father

('Alan','Cathy')

Rules:

brother(X, Y) <= father(Z, X) & father(Z, Y) & ~(X==Y)

cousin(X, Y) <= father(Z, X) & father(W, Y) & brother(Z, W)

grandson(X, Y) <= father(Z, X) & father(Y, Z)

descendent(X, Y) <= father(Y, X) descendent(X, Y) <=

father(Z, X) & descendent(Z, Y)

What are the terms to be created in PyDatalog?

A. Father only

B. Father, brother, cousin, grandson, descendant

C. father, cousin, brother, grandson, descendent, Alan, bill, Cathy, Dany, Ellen, Furon

D. father, cousin, brother, grandson, descendent, Z, a, b, c, d, e, f, X, Y, W

ANSWER : D

5 29 Output Of the Following Program Is:

fromsympy import * x = Symbol('x')

diffren = diff(sin(x)*exp(x), x) print("The

derivative is : ", diffren) integration =

integrate(exp(x)*sin(x)) print("The

integration is : ", integration) root =

solve(x**2 - 2, x) print("The roots are : ",

root)

A. The derivative is : exp(x)*sin(x) + exp(x)*cos(x)

The integration is : exp(x)*sin(x)/2 - exp(x)*cos(x)/2 The roots are : [-sqrt(2),sqrt(2)]

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

B. The derivative is : exp(x)*sin(x) + exp(x)*cos(x)

The integration is : exp(x)*sin(x)/4 - exp(x)*sin(x)/2 The roots are : [-sqrt(2),sqrt(2)]

C. The derivative is : exp(x)*sin(x) +sin(x)*cos(x)

The integration is :exp(x)*cos(x)/2 - exp(x)*sin(x)/4 The roots are : [-sqrt(4), sqrt(4)]

D. The derivative is : cos(x)*sin(x) + exp(x)*cos(x)

The integration is : exp(x)*sin(x)/4 - exp(x)*cos(x)/4 The roots are : [-sqrt(2),sqrt(2)]

ANSWER : A

5 30 Output Of the Following Program Is:

fromsympy import * x, y = symbols('x

y') fst_exp = -cos(x)*sin(y) +

sin(x)*sin(y) cot(x + y)

expand(sin(x+y), trig=True) final_exp

=sin(x)*cos(y) + sin(y)*cos(x)

print(final_exp)

A. cot(x)*sin(y) +sin(y)*cos(x)

B. sin(x)*cos(y) +cot(y)*cos(x)

C. cos(x)*cos(y) +sin(y)*cos(x)

D. sin(x)*cos(y) +sin(y)*cos(x)

ANSWER : D

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

Which of the following programming paradigms allow us to write programs and know they
are correct before running them?

a) Automata based Programming Paradigm


b) Logical Programming Paradigm
c) Dependent type Programming Paradigm
d) Imperative Programming Paradigm

2) Which of the following is false regarding dependent types?

a) They allow us to write programs and know they are correct before running them.
b) They allow us to write programs and know they are correct only after running
them.
c) You can specify types that can check the value of your variables at compile time.
d) Its definition depends on a value.

3) Which of the notations is true for <P(x) is true for all values of x in the universe of
discourse=?

a) x∀P(x)
b) ∀P(x)x
c) ∃xP(x)
d) ∀xP(x)

4) Which of the following is false about quantifiers?

a) Notation ∀ is used for Universal quantifier.


b) Notation ∃is used for Existential quantifier.
c) <All men drink tea= is an example of Universal Quantifier
d) <All men drink coffee= is an example of Existential Quantifier.

5) Let P(x) be the predicate <x must take a discrete mathematics course= and let Q(x) be the
predicate <x is a computer science student=.
Which of the following statements is correct for <Everybody must take a discrete
mathematics course or be a computer science student=?

a) ∀x(Q(x) V P(x))
b) ∀x(Q(x)) V ∀x(P(x))
c) ∀x(Q(x) || P(x))
d) ∀x(Q(x) -> P(x))

6) Which of the following is correct for predicate <All men drink coffee=?

a) ∀x men(x) → (x, coffee)


b) drink (x, coffee)→∀x men(x)

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

c) ∀x men(x) → drink (x, coffee)


d) ∀men(x) → drink (x, coffee)

7) Which of the following is correct for predicate <Some boys play football=?
a) ∃x boys(x) → play(x, football)
b) ∃ boys(x) → play(x, football)
c) ∀x boys(x) → play(x, football)
d) ∃x ∀boys(x) → play(x, football)
8) Dependent Type is used to encode ____________ like "for all" and "there exists".
a. Logic Quantifiers
b. Analysing Quantifiers
c. Dependent Quantifiers
d. None of the above
9) <There exists x in the universe of discourse such that P(X) is true= is which Quantifiers
statement?
a. Logical
b. Universal
c. Existential
d. None of these
10) What is the way to determine if a given function is dependant type

a. Result is independent of the argument


b. Result depends upon the usage in the program
c. Result depends on the Value of its argument
d. Result depends on available resources

11) Notation for an Existential Quantifier:

a.∀xP(x)
b.ΣP(x)
c.∅xP(x)
d.∃xP(x)

12) Representation of the following statement:


Every Clock has quartz

a. ∅xclock(x)->quartz(x)
b. ∃xclock(x)->quartz(x)
c. ∀xclock(x)->quartz(x)
d. none of the above

13) Representation of the following statement:


Some leaves are Red

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

a. ∃xleaves(x)->red(x)
b. ∀xleaves(x)->red(x)
c. Σleaves(x)->red(x)
d. none of the above

13. A function has dependent type if the ______of a function's result depends on the _______ of its
Argument

a. value and type

b. type and value

c. type and type

d. value and value

14. Dependent type paradigm used to encode logic's quantifiers like _____and _______

a. for one, there may exists

b. for all, there always

c. for all, there exists

d. for specific, there exists

15. Choose the correct one with respect to typing and typing-extensions library in python dependent
type programming.

a. typing is not builtin python module where all possible types are defined.
typing_extensions is an official package for new types in the future releases of python
b. typing is a builtin python module where all possible types are defined.
typing_extensions is an official package for new types in the future releases of python
c. typing is a builtin python module where all possible types are defined.
typing_extensions is not an official package for new types in the future releases of python
d. typing is not a builtin python module where all possible types are defined.
typing_extensions is not an official package for new types in the future releases of python

16. Predict the output of the below mentioned python code without dependent type syntax:

def make_hamburger(meat, number_of_meats):


return ["bread"] + [meat] * number_of_meats + ["bread"]
print(make_hamburger("ground beef", 2))

a. ['bread', 'ground beef', 2, 'bread']


b. ['bread', 'ground beef', 'ground beef', 'bread']
c. TypeError: cannot concatenate 'str' and 'int' objects

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

d. ['bread', 'ground beef', '2bread']

17. Predict the output of the below mentioned python code with dependent type syntax:
from typing import List

def greet_all(names: List[str]) -> None:


for name in names:
print('Hello ' + name)

names = ["Alice", "Bob", "Charlie"]


ages = [10, 20, 30]

greet_all(names)
greet_all(ages)

a.greet_all(names) # Ok!
greet_all(ages) # Ok!

b. a.greet_all(names) # Ok!
greet_all(ages) # Error due to incompatible types

c. a.greet_all(names) # Error due to incompatible types


greet_all(ages) # Ok!

d. a.greet_all(names) # Error due to incompatible types


greet_all(ages) # Error due to incompatible types

18 Let x be a variable which refers to Universe of Disclosure such as x1,x2....xn then


,how to represent this statement using quantifiers < All Man working in
Industry=
a) ∀x man(x) → work (x, Industry) b)∀x man(x) → work(industry).
a) ∀x → work (x, industry) d)∀x man(x) → Industry(work)

19 How do you represent the statement <Every man respects his parent.=
a) ∀x woman(x) → respects (x, parent) b) ∀x man(x) → respects (x, parent)

c) ∀x man → respects (x, parent) d) ∀x man(x) → respects ( parent).

20 How do you represent the statement <Some boys play cricket <
a) ∃x boys(x) → play(all) b) ∀x boys(x) → play(x, cricket)
c) ∃x boys(x) → play(x, cricket) d)∃x^ ∀x boys(x) → play(x, cricket)

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

SRM INSTITUTE OF SCIENCE AND TECHNOLOGY


VADAPALANI CAMPUS
DEPARTMENT OF COMPUTER SCIENCE AND TECHNOLOGY

18CSC207J – ADVANCED PROGRAMMING PRACTICES

NETWORK PROGRAMMING PARADIGM

1. _____________ programming is a way of connecting two nodes on a network to


communicate with each other.
i. Logic
ii. Socket
iii. Functional
iv. Symbolic

2. Which method used by the server to initiate the connection with the client?
i. Listen()
ii. Close()
iii. Bind()
iv. Accept()

3. _____________is a socket through which data can be transmitted continuously.


i. Datagram Socket
ii. Stream Socket
iii. Raw Socket
iv. Binary Socket

4. _____________ paradigm deals with client – server communication


i. Dependent type paradigm
ii. Parallel programming paradigm
iii. Network paradigm
iv. Concurrent programming paradigm

5. _____________ protocol facilitates sending of datagrams in an unreliable manner.

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

i. TCP
ii. UDP
iii. HTTP
iv. FTP

6. Which among methods are not server socket?


i. connect( )
ii. bind( )
iii. listen()
iv. accept()

7. In UDP, Which among methods are used to receive messages at endpoint


i. sock_object.recv()
ii. sock_object.send()
iii. sock_object.recvfrom()
iv. sock_object.sendto()

8. In TCP, Which among methods are used to send messages from endpoint
i. sock_object.recv()
ii. sock_object.send()
iii. sock_object.recvfrom()
iv. sock_object.sendto()

9. The protocol which defines IPv4 is


i. AF_UNIX
ii. SOCK_STREAM
iii. AF_INET
iv. SOCK_DGRAM

10. The correct order of methods used in server socket is


i. Socket(), Bind(), listen(), accept()
ii. Socket(), listen(), bind(), accept()
iii. Socket(), accept(), bind(), listen()
iv. Socket(), bind(), accept(), listen()

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

11. ____________ is a type of network socket which provides connection less point for
sending and receiving packets.
i. Datagram Socket
ii. Stream Socket
iii. Raw Socket
iv. Binary Socket
12. ___________ do not use any transport protocol but data is directly transmitted over
IP protocol
i. Datagram Socket
ii. Stream Socket
iii. Raw Socket
iv. Binary Socket
13. The __________ is a physical path over which the message travels.
i. Protocol
ii. Medium
iii. Path
iv. Route
14. A pair (host, port) is used for the _____ address family.
i. AF_NETLINK
ii. AF_INET6
iii. AF_INET
iv. AF_ALG
15. Use _____________ to make the socket to visible to the outside world.
i. socket.listen()
ii. socket.visible()
iii. socket.socket()
iv. Socket.gethostname()
16. In which mode socket is created in default.
i. Blocking mode
ii. Non-Blocking Mode
iii. Timeout mode
iv. Accept mode
17. Which method is recommended to be called before calling connect() method?
i. getdefaulttimeout()

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

ii. settimeout()
iii. getaddrinfo()
iv. no such method
18. Which exception is raised for address related errors by getaddrinfo()?
i. gaoerror
ii. gsierror
iii. gaierror
iv. gdeerror
19. _____________ protocol facilitates sending of datagrams in an reliable manner.
i. TCP
ii. UDP
iii. HTTP
iv. FTP
20. To create a socket, which function among the following is available in python socket
module?
i. socket.create()
ii. socket.initialize()
iii. socket.socket()
iv. socket.build()

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

1. What does a threading.Lock do?

a) Pass messages between threads b) Allow only one thread at a time to access a resource
c) Wait until a thread is finished d) SHIFT TO ALL CAPS

2. What does the Thread.join() method do?


a) Waits for the thread to finish b) Restricts access to a resource
c) Adds the thread to a pool d) Merges two threads into one

3) Race conditions are …


a) Testing which thread completes first b) Two threads incorrectly accessing a shared resource
c) The weather on race day d) Something you should add to your code

4) It sets the lock state to locked. If called on a locked object, it blocks until the resource is free.

a) lock() b)release() c) acquire() d)join()

5) You have thread T1, T2, and T3. How will you ensure that thread T2 is run after T1 and thread T3 after
T2?
a) Sleep method b) Join Method c)Release d)lock method

6) What are the libraries in Python that support threads?

_threading b) Thread c)None d)thread

7) Mention the correct syntax for creating Thread object for calling increment methods

a) t1 = threading.Thread() b) t1 = threading.Thread(target)

c) t1 = threading.Thread(target=incr) d) t1 = threading.Thr

8) Which leads to concurrency?


a) Serialization b) Parallelism c) Serial processing d) Distribution

9) Which is not a method for parallelism?

a) Message Passing b) Shared Memory c) Threads d) Sockets

10) A race condition occurs when multiple processes or threads read and write

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

a). Input b). Information c). Data Items d). Programs

11) For a single processor system, implementation of semaphores is possible to inhibited through

a) Deadlock b) Interrupts c) Lock Step d) Paging

12) Which method controls the execution of thread in python?

a) Wait b) Sleep c) Acquire d) Lock

13) How does run() method is invoked?

a) By Thread.create() b) By Thread.start()

c) None d) By Thread.run()

14) What is the difference between threading.Lock and threading.RLock?

a) Lock and RLock both primitives are owned by a single thread.

b) Lock is owned by none while RLock is owned by many.

c) Lock is owned by a thread while RLock is owned by many.

d) Lock and RLock both primitives are owned by many.

15) What is the difference between a semaphore and bounded semaphore?

a) Semaphore holds a counter for the number of release() calls minus the number of acquire() calls, plus
an initial value but bounded semaphore doesn't.
b) A semaphore makes sure its current value doesn’t exceed its initial value while bounded semaphore
doesn't.
c) A bounded semaphore makes sure its current value doesn’t exceed its initial value while
semaphore doesn't.
d) Bounded semaphore holds a counter for the number of release() calls minus the number of acquire()
calls, plus an initial value but semaphore doesn't.

16) What is the method that wakes up all thread waiting for the condition?

a) releaseAll() b) notify() c) notifyAll() d) release()

17 How to terminate a blocking thread?

a). thread.stop() & thread.wait() b) thread.stop()


c) thread.terminate() d) None

18. Which synchronization method is used to guard the resources with limited capacity, e.g. a database
server?

a) Event b) Condition c) Lock d) Semaphore

19. How to detect the status of a python thread?

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

a) isActive() b) isDaemon() c) None d) isAlive()

20. Execution of several activities at the same time.

a) processing b) parallel processing c) serial processing d) multitasking

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

1.SymPy is a collection of mathematical algorithms and convenience functions built on the


-----------extension of Python

a)numpy b)scikit
c)sys d) functools

2. Exponential function computes the ----------------

a) 10**x element-wise b) 10**x row-wise


c) 10**x column-wise d) 10*x element-wise

3.___________ evaluates the expression to a floating-point number.

a)evalf b)fval

c) float d) valf

4. what is the output for the following expression ((x+y)**2).expand()

a) x,2 + 2,x,y + y,2 b) x*2 + 2*x*y + y*2

c) x^2 + 2*x*y + y^2 d) x**2 + 2*x*y + y**2

5. limit((5**x + 3**x)**(1/x), x, oo) ,what is the output

a)5 b) oo

c) 1 d) 0

6) Higher derivatives can be calculated using the which method

a) highder(func,var,n) b) diff(func, var, n)

c) diff(n,var,func) d) diff(func, var)

7) what is the output

>>> x = Symbol('x')

>>> y = Symbol('y')

>>> A = Matrix([[1,x], [y,1]])

>>> A**2

a) [1, x] b) [xy + 1, 2x]


[y, 1] [2y, xy + 1]

c) [x*y + 1, 2*y] d) [x*y + 1, 2*x]

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

[2*x, x*y + 1] [ 2*y, x*y + 1]

8) .match() method, along with the ------- class, to perform pattern matching on expressions.

a) pattern b) func

c) wild d) dictionary

9) which among the following function Return or print, respectively, a pretty representation of expr

a) pretty(expr) b) pretty_print(expr)

c) pprint(expr) d) all of the above

10) What is the output of

from sympy.abc import a, b

expr = b*a + -4*a + b + a*b + 4*a + (a + b)*3

a) ba-4a+b+ab+4a+3(a+b) b) 2*a*b + 3*a + 4*b

c) 2ab+3a+4b d) all of the above

11) print(pi.evalf(30))

a) 3.14/30 b)30/3.14

c)3.14159265358979323846264338328 d) 3.14

12) which is the correct way to write equation for x^2=x in sympy

a) x**2 =x b) x*x = x

c) x%2 = x d) X^2 =x

13) how to find a solution for a equation in a given interval

a) solve(equation,range) b)equation(solve,range)

c) solveset() d) both a and b

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

14) Allows , the same elements can appear multiple times at different positions

a) set b)sequence

c) dictionary d) none

15) which is the snippet to find the eigenvalues of [1 2

2 2]

a) Matrix([[1, 2], [2, b) Matrix([[1, 2], [2, 2]]).eigen


2]]).eigenvals()

c) both a and b d) eigen(([[1, 2], [2, 2]])

16 What is the purpose of sympify() method?


a. Convert expression of string type to mathematical expression
b. Convert mathematical expression to String
c. Convert mathematical expression to character
d. Convert tuple to mathematical expression
17 Find the output of the following program
from sympy import solve
x = Symbol('x')
expr = x**2 + 5*x + 4
solve(expr, dict=True)

a. [{x: -4}, {x: -1}]


b. [{x: -6}, {x: -1}]
c. [{x: -1}, {x: -4}]
d. [{x: 4}, {x: -1}]
18. A rational expression is an algebraic expression in which the numerator and denominator
are both --------------
a. Equal
b. Polynomials
c. Unequal
d. Symmetric
19. Find the output of the following program
# import sympy
from sympy import *

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

x = symbols('x')
expr = sin(x)/x;
print("Expression : {}".format(expr))

# Use sympy.limit() method


limit_expr = limit(expr, x, 0)
print("Limit of the expression tends to 0 : {}".format(limit_expr))

a. Expression : cos(x)/x
Limit of the expression tends to 0 : 2
b. Expression : tan(x)/x
Limit of the expression tends to 0 : 3
c. Expression : sin(x)/x
Limit of the expression tends to 1 : 0
d. Expression : sin(x)/x
Limit of the expression tends to 0 : 1
20. -------------- method will simplify mathematical expression using trigonometric identities.
a. sympy.trigsimp()
b. sympy.series()
c. sympy.lambda()
d. sympy.sim()

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

UNIT V
PART A: MULTIPLE CHOICE QUESTIONS
Symbolic:
1. Which of the following is false about sympy? (CLO5-L1)
a. Sympy is a python library for symbolic mathematics
b. It requires external libraries for execution
c. It is an alternative to the systems like mathematica or maple
Ans: B
2. Symbols can now be manipulated using some of python operators using _____.(CLO5-L1)

A)+. B) && C) ? D$

Ans: A

3. Which of the following belongs to the numerical type of sympy (CLO5-L1)


a. Float
b. Integer
c. Decimal
d. Factorial
Ans: B
4. Choose the correct output for the following code?(CLO5-L2)
Import sympy as sym
a= sym.Rational(4,6)
print a
a. 6/4
b. 0.66
c. 4/6
d. 1.5
Ans: C
5. What is the output for the trigonometry function? (CLO5-L2)
Sym.expand(sym.cos(x+y),trig=true)
a. sin(x)*sin(y)+cos(x)*cos(y)
b. sin(x)*cos(y)+cos(x)*sin(y)
c. -sin(x)*sin(y) - cos(x)*cos(y)
d. -sin(x)*sin(y) + cos(x)*cos(y)
Ans: D
6. Differentiate the Sympy Expression using the syntax (CLO5-L1)
a. diff (var,func)
b. diff(func,var)
c. diff(expr,var)
d. diff(var,point)
Ans: B
7. SymPy is able to solve algebraic equations, in one and several variables using(CLO5-L1)

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

a. solveset()
b. series()
c. real()
d. limit()
Ans: A
8. Which of the following belongs to the calculus function? (CLO5-L1)
i. Limit
ii. Series
iii. Arithmetic
iv. Computation
a. Both i,ii
b. Both ii,iii
c. Both ii,iv
d. Both i,iii,iv
Ans: A
9. Choose the output for the following code? (CLO5-L2)
Limit (sin(x), x,0)
a. 0
b. 1
c. Infinite
d. Error
Ans: B
10. Which of the following is the correct output for the below given code? (CLO5-L2)
Sym.integrate(x**3, (x,-1,1)
a. 1
b. 3
c. 0
d. -1
Ans: C
11. Which of the following is the correct output for the below given code? (CLO5-L2)
x,y=sym.symbols(8x,y9)
A=sym.Matrix([[1,x],[y,1]])
Print A
a. Matrix ([[1,x], [y,1]])
b. Matrix ([[x,1],[1,y]])
c. Matrix ([[0,x], [y,0]])
d. Matrix ([[x,0],[0,y]])
Ans: A
12. Choose the output for the following code? (CLO5-L2)
Sym.solveset(x**4-1,x)
a. {1,-1,I,-I}
b. {-1,1,-I,I}
c. {0,1,I,-I}
d. {1,-1,-I,I}

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

Ans: B
13. Limit the Sympy Expression using the syntax (CLO5-L1)
a. limit (var,func,point)
b. limit(func,var,point)
c. limit(func,var)
d. limit(var,point)
Ans: B
14. Finite state machines are used for____(CLO5-L1)
a. Pseudo random test patterns
b. Deterministic test patterns
c. Random test patterns
d. Algorithmic test patterns

Ans:D

15. According to the given transitions, which among the following are the epsilon closures of q1 for
the given NFA? (CLO5-L3)
Δ (q1, ε) = {q2, q3, q4}
Δ (q4, 1) =q1
Δ (q1, ε) =q1
a. q4
b. q2
c. q1
d. q1, q2, q3, q4

Ans: D

16. Which of the following tuples order are correct for Deterministic Finite Automata (DFA) (CLO5-
L1)
a. (Q, S, d, q0, F)
b. (Q, S, d, F,q0)
c. (S,Q, d, q0, F)
d. (Q, S, q0, d, F)

Ans: A

17. NFA, is called as9non-deterministic9 because of :(CLO5-L1)


a. The result is undetermined
b. The choice of path is non-deterministic
c. The state to be transited next is non-deterministic
d. All of the mentioned

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

Ans: B

18. _______ is a class attribute defined by its source state and destination state. .(CLO5-L1)
a. LGPL
b. Scipy
c. Transition
d. State

Ans : C

19. Among the following which is used to define the behavior of what we want to achieve (CLO5-L1)
a. State
b. Automata
c. Transition
d. Machine

Ans: D

20. _________is a triplet consisting of two states and one command needed for the change of one
state to the other. .(CLO5-L1)
a. machine
b. Automata
c. State
d. Transitions

Ans:D

21. _________is a mathematical model of computation. .(CLO5-L1)


a. state machine
b. Automata
c. State
d. Transitions

Ans: A

22. Which of the following is correct among the following expressions? (CLO5-L2)
i.

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

ii.

iii.

a. Both i,ii
b. Both ii,iii
c. Both i,iii
d. All of the above

Ans: A

23. What kind of abstract machine can recognize strings in a regular set? (CLO5-L1)

a. DFA

b. NFA

c. PDA

d. None of the above

Ans: A

24. Which of the following statements is wrong? (CLO5-L1)


a. The language accepted by finite automata are the languages denoted by regular expressions
b. For every DFA there is a regular expression denoting its language
c. For a regular expression r, there does not exist NFA with L(r) any transit that accept
d. None of the above.

Ans: C

25. Let for ∑= {0,1} R= (∑∑∑) *, the language of R would be--------


(CLO5-L2)

a. {w | w is a string of odd length


b. {w | w is a string of length multiple of 3}
c. {w | w is a string of length 3}
d. All of the above.

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

Ans: B

26. (a+b)* is equivalent to------- (CLO5-L2)


a. b*a*
b. (a*b*)*
c. a*b*
d. None of the above.

Ans: B

27. In regular expressions, the operator 8*9 stands for------ (CLO5-L1)


a. Concatenation
b. Addition
c. Selection
d. Iteration

Ans: D

28. The regular expression with all strings of 0′s and 1′s with at least two consecutive 0′s is------
(CLO5-L2)
a. 1 + (10)* yh
b. (0+1)*011
c. (0+1)*00(0+1)*
d. 0*1*2*

Ans: C

29. Which of the following operation can be applied on regular expressions? (CLO5-L1)
a. Union
b. Concatenation
c. Closure
d. All of the above

Ans: D

30. Finite state machine will initially set to all zeroes. (CLO5-L1)
a. True
b. False

Ans: A

31. _______ allow millions of different machines, using all sorts of different network hardware, to
pass packets to each other over the fabric of an IP network.(CLO5-L1)
a)Sockets

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

b)Client machine
c)server machines
d)IP address
Ans: d
32. Which are all necessary to direct a packet to its destination.(CLO5-L2)
a)IP Address b)IP address and port c)port d)InternetAssignedNumbers
Ans:b
33. ________ (0–1023) are for the most important and widely-used protocols(CLO5-L1)
a. Well Known ports b)Registered ports c)Known ports d)Unregistered ports
Ans:a
34. ___________ (1024–49151) are not usually treated as special by operating systems(CLO5-L1)
a)Registered ports b)well known ports c)Known ports d)Unregistered ports
Ans:a
35. Python9s standard socket module supports _______(CLO5-L1)
a)getByName() b)getName() c)gethostbyname() d)getServName()
Ans:c
36. Example for Connection oriented protocol(CLO5-L1)
a)UDP b)SMTP c)FTP d)TCP
Ans:d
37. Example for Connection less protocol(CLO5-L1)
a)SMTP b) FTP c)UDP d)TCP
Ans:c
38. _________ is an application-level block of transmitted data.(CLO5-L1)
a)data b)datagram c)segmentation d)Fragmentation
Ans:b
39. Simple server uses ______ command to request a UDP network address.(CLO5-L1)
a)bind() b)scocket() c)getName() d)getsockName()
Ans:a
40. Which method is used by python program to retrieve the current IP and port to which the socket is
bound. (CLO5-L2)

a)bind() b)getsockname() c)getName() d)getSocket()

Ans:b
41. Sending packets with another computer9s return address is called ________(CLO5-L1)
a)Binding b) Unification c)Spoofing d) IP address
Ans:c
42. The concept by which larger UDP packets are spitted into several small physical
packets(CLO5-L1)
a)fragmentation b)Binding c) Unification d) partition
Ans:a
43. The MTU is _____ that all of the network devices between two hosts will support. (CLO5-L1)
a)smallest packet size b)medium packet size c)average packet size d)largest packet size
Ans:d
44. ______ is efficient only if your host ever only sends one message at a time, then waits for a
response.(CLO5-L1)
a)UDP b)TCP c)FTP d)SMTP
Ans: a
45. Which protocol provides reliable connection?(CLO5-L2)
a)UDP b) FTP c)TCP d)SMTP
Ans:c
46. TCP uses a ______ that counts the number of bytes transmitted.(CLO5-L1)
a) protocol b)counter c)rules d)Ports
Ans:b

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

47. The amount of data that a sender is willing to have on the wire at any given moment is called
____(CLO5-L1)
a) The size of the TCP window. b) counter c) port d) protocol

Ans:a

48. TCP uses _______ to distinguish different applications running at the same IP address, and
follows exactly the same conventions regarding well-known and ephemeral port numbers.(CLO5-
L1)
a) IP address b)port c)port numbers d) socket ID
Ans:c
49. _______refers to the address family ipv4.(CLO5-L1 (CLO5-L1)
a) Af_INET b) AS_INET c) AG_INET d) AN_INET

Ans:a
50. A server has a ______method which puts the server into listen mode.(CLO5-L1)

a)list() b)listento() c)listen() d)listenfrom()

Ans:c
51. ______ are the end-point of a two-way communication .(CLO5 L1) a)IP
Address b)sockets c)sockets ID d) Object ID
Ans:b

52. Identify the method used to connect the client to host and port and initiate the connection towards
the server.(CLO5-L3)
a)sock_object.recv() b)sock_object.send()
c)sock_object.append() d)sock_object.connect():
Ans:d
53. Identify the method to receive messages at endpoints when the value of the protocol parameter is
TCP.(CLO5-L3)

a)sock_object.recv() b)sock_object.send()
c)sock_object.append() d)sock_object.connect():

Ans:a

54. Which method is used to receive messages at endpoints if the protocol used is UDP.(CLO5-L2)
a)sock_object.recv() b)sock_object.recvfrom()
c)sock_object.append() d)sock_object.connect():

Ans:b
55. Identify the method that returns host name.(CLO5-L1)

a)sock_object.recv() b)sock_object.recvfrom()
c)sock_object.gethostname d)sock_object.connect():
Ans:c
56. Identify the method to send messages from endpoints if the protocol parameter is UDP.(CLO5-
L3)

a)sock_object.sendto(): b)sock_object.recvfrom()
c)sock_object.gethostname d)sock_object.connect():
Ans:a

57. ________can be used to end direction of communication in a socket(CLO5-L1)


a. The shutdown() call b)Shut() c)close() d)end()

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

Ans:c

PART: B (4MARKS)

1) Write a program to factorize the following expression. (CLO5-L3)


x**3 + 3*x**2*y + 3*x*y**2 + y**3
2) What is SymPy? (CLO5-L1)
3) Write the commands to perform the operations on substitutions and expressions (CLO5-
L1)
4) Design a DFA that accepts all strings that contain 010 or do not contain 0. (CLO5-L2)
5) Differentiate Finite state machine and Non deterministic Finite state machine. (CLO5-L2)
6) Let Σ = {0, 1}. Give DFAs for {}, {ε}, Σ*, and Σ+. (CLO5-L2)

7)
Provide the DFA function for the above-mentioned diagram (CLO5-L2)
8) Compare the features of LISP and Wolfram. (CLO5-L2)
9) Write a DFA automata code for L(M) ={ w | w has an even number of 1s} (CLO5-L2)
10) Write a DFA automata code for L(M)={(ab)n | n N}(CLO5-L2)
11) Construct NFA that recognizes the language of strings that end in 01 (CLO5-L2)
12) Find an NFA to recognize the language (a + ba)*bb(a + ab)*. (CLO5-L2)
13) Write the features of GUI programming. (CLO5-L1)
14) Explain briefly Automata based programming in python. (CLO5-L1)
15) Write the syntax for Expand and Factor command. Give example. (CLO5-L1)
16) Give example for DFA and explain. (CLO5-L2)
17) Differentiate Python and Jpython. (CLO5-L2)
18) Write the syntax for series and Integration command. Give example .(CLO5-L1)
19) Give example for NFA and explain. (CLO5-L1)
20) Differentiate TCP and UDP(CLO5-L2)
21) Compare connection oriented and connectionless service(CLO5-L2)
22) Differentiate automatic and manual configuration(CLO5-L2)
23) How will you generate random port numbers?(CLO5-L2)
24) What is file descriptors? Give example(CLO5-L1)
25) Differentiate bind() and getSockName() .(CLO5-L2)
26) What is UDP fragmentation? Give example .(CLO5-L1)
27) What will happen when you send large packets? Give example.(CLO5-L2)
28) Differentiate multicast and broadcast.(CLO5-L2)
29) Write the code to connect server and client in TCP.(CLO5-L3)
30) How does TCP provides reliable connection.(CLO5-L2)

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

31) Compare passive and active socket.(CLO5-L2)


32) Write the code to connect server and client in UDP.(CLO5-L3)

PART-C (12 MARKS)

1. Write a program to expand and factorize the following expression. (CLO5-L3)

a. x3 + 3x2y + 3xy2 + y3 = (x + y)3


b. x + y + x*y

2. Consider the following series:

X+(X2/2) + (X3/3) + (X4/4) +……+(Xn/N)

Write a python program that will ask a user to input a number, n, and print this series for that number.
In the series, x is a symbol and n are an integer input by the program9s user. The nth term in this series
is given as (Xn/N). (CLO5-L3)

3. Write a program to implement client server communication using UDP. (CLO5-L3)


4. Write a program to demonstrate the concept of UDP fragmentation and explain .(CLO5-L3)
5. Explain automata-based programming paradigm. (CLO5-L1)

6. Design go, slowdown and stop events according to the traffic scenario to cross the road using python
code and also draw transition diagram and transition table for the same scenario. (CLO5-L3)

7. Write a example program to find limits, differentiation, Series and Integration. (CLO5-L1)

8. Differentiate DFA and NFA. Explain NFA with example. (CLO5-L2)

9. Build an automaton that accepts all and only those strings that contain 001 (CLO5-L2)
10. Find an DFA for each of the following languages over the alphabet {a, b}.(CLO5-L3)

(a) {(ab)n | n N}, which has regular expression (ab)*.


b) Find a DFA for the language of a + aa*b.
11.a. Write NFA automata code for the Language that accepts all end with 01 (CLO5-L3)
b. Write a automata code for L(M)= a + aa*b + a*b.
c Write a automata code for Let Σ = {0, 1}.

Given NFAs for {}, {ε}, {(ab)n | n N}, which has regular expression (ab)*.

12. Write a program to convert NFA to DFA (CLO5-L2)

13. Explain in detail about communication using UDP with example. .(CLO5-L1)

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

UNIT 4

Dependent Programming paradigm, parallel and concurrent Programming paradigm

1. Parallelism representation is critical to the success of ---------------------- (CLO-4,L1)

a)High-performance computing.b)Low-performance computing

c)Scaling d)Vectorization

Ans:a

2. Parallel programming through a combination of -----------and ------------(CLO-4,L1)

a.Patterns, examples

b.Algorithms , flowcharts

c.Models , methods

d.Classes ,objects

Ans:a

3.What is multithreaded programming? (CLO-4,L1)

a) It’s a process in which two different processes run simultaneously

b) It’s a process in which two or more parts of same process run simultaneously

c) It’s a process in which many different process are able to access same information

d) It’s a process in which a single process can access information from many sources

Ans:b

4. Which of these are types of multitasking? (CLO-4,L2)

a) Process based

b) Thread based

c) Process and Thread based

d) None of the mentioned

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

Ans:c

5.What will happen if two thread of the same priority are called to be processed
simultaneously? (CLO-4,L2)

a) Anyone will be executed first lexographically

b) Both of them will be executed simultaneously

c) None of them will be executed

d) It is dependent on the operating system

Ans:d

6. Which of these statements is incorrect? (CLO-4,L2)

a) By multithreading CPU idle time is minimized, and we can take maximum use of it

b) By multitasking CPU idle time is minimized, and we can take maximum use of it

c) Two thread in Java can have the same priority

d) A thread can exist only in two states, running and blocked

Ans:d

7. Identify the technique that allows more than one program to be ready for execution and
provides the ability to switch from one process to another. (CLO-4,L2)

a) multitasking

b) multiprocessing

c) multitasking

d) multiprogramming

Ans:d

8. The technique that increases the system’s productivity. (CLO-4,L1)

a) multiprogramming

b) multitasking

c) multiprocessing

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

d) single-programming

Ans:a

9. _____________is a property which more than one operation can be run simultaneously but it
doesn’t mean it will be. (CLO-4,L1)

a. Concurrency

b.Semaphore

c.Mutual exclusion

d.parallel process

Ans:a

10.____________ is a light-weight cooperatively-scheduled execution unit.(CLO-4,L3)

a. gevent.Greenlet

b. gevent.spawn()

c.gevent.spawn_later()

d.gevent.spawn_raw()

Ans:a

11. Which keyword is used to define methods in Python? (CLO-4,L2)

(a) function
(b) def
(c) method
(d) All of these

Ans:B

12. What is the correct translation of the following statement into mathematical logic? <Some
real numbers are rational= .(CLO-4,L3)

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

Ans: c

13. Which one of the following options is CORRECT given three positive integers x, y and z, and
a predicate? .(CLO-4,L3)

P(x) = ¬(x=1)'∀y(∃z(x=y*z)⇒(y=x)((y=1))

P(x) being true means that x is a prime number

P(x) being true means that x is a number other than 1

P(x) is always true irrespective of the value of x

P(x) being true means that x has exactly two factors other than 1 and x

Ans: a

14. Suppose the predicate F(x, y, t) is used to represent the statement that person x can fool
person y at time t. which one of the statements below expresses best the meaning of the
formula ∀x∃y∃t(¬F(x, y, t))? .(CLO-4,L3)

(a) Everyone can fool some person at some time

(b) No one can fool everyone all the time

(c) Everyone cannot fool some person all the time

(d) No one can fool some person at some time

Ans: b

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

15. Which one of the following is the most appropriate logical formula to represent the
statement? <Gold and silver ornaments are precious=. (CLO-4,L3)

The following notations are used:

G(x): x is a gold ornament

S(x): x is a silver ornament

P(x): x is precious

(a) ∀x(P(x)→(G(x)'S(x)))

(b) ∀x((G(x)'S(x))→P(x))

(c) ∃x((G(x)'S(x))→P(x)

(d) ∀x((G(x)(S(x))→P(x))

Ans : d

16. Which one of the first order predicate calculus statements given below correctly express the
following English statement? .(CLO-4,L3)

Tigers and lions attack if they are hungry or threatened.

Ans: d

17. What is the first order predicate calculus statement equivalent to the following? (CLO-4,L3)

Every teacher is liked by some student

(A) ∀(x) [teacher (x) → ∃ (y) [student (y) → likes (y, x)]]

(B) ∀ (x) [teacher (x) → ∃ (y) [student (y) ^ likes (y, x)]]

(C) ∃ (y) ∀ (x) [teacher (x) → [student (y) ^ likes (y, x)]]

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

(D) ∀ (x) [teacher (x) ^ ∃ (y) [student (y) → likes (y, x)]]

Ans: b

18.

Which of the above two are equivalent? (CLO-4,L3)

(A) I and III

(B) I and IV

(C) II and III

(D) II and IV

Ans: b

19. ________is a builtin python module where all possible types are defined. .(CLO-4,L2)

(a) overload

b)typing

c)function

d)literal

Ans: b

20. ___________type represents a specific value of the specific type. .(CLO-4,L1)

a) overload

b) typing

c) literal

d) None of the above

Ans: c

21. __________ is required to define multiple function declarations with different input types
and results. .(CLO-4,L1)

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

a) overload

b) typing

c) literal

d) None of the above

Ans: a

PART B:(4 MARKS)


1. State parallel programming paradigm. (CLO-4, L1)

2. Differentiate parallel programming with functional programming. (CLO-4, L2)

3. Explain about Multithreading. (CLO-4, L1)

4. Explain about Multiprocessing. (CLO-4, L1)

5. Relate Serial processing concepts in Python. (CLO-4, L3)

6. Differentiate Serial Processing and Parallel Processing. (CLO-4, L3)

7. Demonstrate Multiprocessing module in Python. (CLO-4, L3)

8. Describe about Process class. (CLO-4, L2)

9. Design a Pool class in Python.(CLO-4, L3)

10. State Concurrent programming paradigm. (CLO-4, L1)

11. Compare multiprocessing and multitaking. (CLO-4, L2)

12.What are dependent functions ?(CLO4-L1)

13. Define typing module in dependent type programming? (CLO-4, L2)

14.Define dependent functions? (CLO-4, L2)

15.What is predicate logic? (CLO-4, L2)

16.Different types of quantifiers. (CLO-4, L1)

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

17.Explain Universal Quantifier and Existential Quantifier (CLO-4, L1)

18.Write some examples of Universal Qunatifier. (CLO-4, L2)

19 Define overload and literal in dependent type programming (CLO-4, L2)

20. Write the syntax for Existential Quantifier. (CLO-4, L2)

PART :C(12 MARKS)

1. Write a python program to implement producer consumer problem. (CLO-4, L3)

2. Implement the concept <Pool class= by importing a package pool. (CLO-4, L3)

3. Write a python program to implement dinning philosopher problem. (CLO-4, L3)

4. Explain the differences between multithreading and multiprocessing with example? (CLO-4,
L1)

5.Write a program to implement thread synchronization (CLO-4, L3)

6. Compare Concurrent programming paradigm and functional programming paradigm with


example program. (CLO-4, L2)

7. Explain in detail about dependent type programming .(CLO4-L1)

8. Write a python program to create Type aliases using typing module. . (CLO-4, L3)

9. Write a python program to check every key:value pair in a dictionary and check if they match
the name:email format using typing module. . (CLO-4, L3)

10. Write a python program to create new user defined type Student using typing module. .
(CLO-4, L3)

11. Write a python program for function dependent type using overload and literals . . (CLO-4,
L3)

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

Automata is a Python 3 library which implements the structures and algorithms for finite automata, pushdown
automata, and Turing machines.

Automata requires Python 3.4 or newer.

Installing

You can install the latest version of Automata via pip:

pip install automata-lib

API

The Automaton class is an abstract base class from which all automata (including Turing machines) inherit. As
such, it cannot be instantiated on its own; you must use a defined subclasses instead (or you may create your
own subclass if you’re feeling adventurous). The Automaton class can be found under automata/base/automaton.py .

If you wish to subclass Automaton , you can import it like so:

from automata.base.automaton import Automaton

The following methods are common to all Automaton subtypes:

Automaton.read_input(self, input_str)

Reads an input string into the automaton, returning the automaton’s final configuration (according to its
subtype). If the input is rejected, the method raises a RejectionException .

Automaton.read_input_stepwise(self, input_str)

Reads an input string like read_input() , except instead of returning the final configuration, the method returns a
generator. The values yielded by this generator depend on the automaton’s subtype.

If the string is rejected by the automaton, the method still raises a RejectionException .

Automaton.accepts_input(self, input_str)

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

Reads an input string like read_input() , except it returns a boolean instead of returning the automaton’s final
configuration (or raising an exception). That is, the method always returns True if the input is accepted, and it
always returns False if the input is rejected.

Automaton.validate(self)

Checks whether the automaton is actually a valid automaton (according to its subtype). It returns True if the
automaton is valid; otherwise, it will raise the appropriate exception (e.g. the state transition is missing for a
particular symbol).

This method is automatically called when the automaton is initialized, so it’s only really useful if a automaton
object is modified after instantiation.

Automaton.copy(self)

Returns a deep copy of the automaton according to its subtype.

class FA(Automaton, metaclass=ABCMeta)

The FA class is an abstract base class from which all finite automata inherit. The FA class can be found
under automata/fa/fa.py .

If you wish to subclass FA , you can import it like so:

from automata.fa.fa import FA

class DFA(FA)

The DFA class is a subclass of FA and represents a deterministic finite automaton. It can be found
under automata/fa/dfa.py .

Every DFA has the following (required) properties:

1. states : a set of the DFA’s valid states, each of which must be represented as a string
2. input_symbols : a set of the DFA’s valid input symbols, each of which must also be represented as a string
3. transitions : a dict consisting of the transitions for each state. Each key is a state name and each value is
a dict which maps a symbol (the key) to a state (the value).
4. initial_state : the name of the initial state for this DFA
5. final_states : a set of final states for this DFA

from automata.fa.dfa import DFA

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

# DFA which matches all binary strings ending in an odd number of '1's

dfa = DFA(

states={'q0', 'q1', 'q2'},

input_symbols={'0', '1'},

transitions={

'q0': {'0': 'q0', '1': 'q1'},

'q1': {'0': 'q0', '1': 'q2'},

'q2': {'0': 'q2', '1': 'q1'}

},

initial_state='q0',

final_states={'q1'}

DFA.read_input(self, input_str)

Returns the final state the DFA stopped on, if the input is accepted.

dfa.read_input('01') # returns 'q1'

dfa.read_input('011') # raises RejectionException

DFA.read_input_stepwise(self, input_str)

Yields each state reached as the DFA reads characters from the input string, if the input is accepted.

dfa.read_input_stepwise('0111')

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

# yields:

# 'q0'

# 'q0'

# 'q1'

# 'q2'

# 'q1'

DFA.accepts_input(self, input_str)

if dfa.accepts_input(my_input_str):

print('accepted')

else:

print('rejected')

DFA.validate(self)

dfa.validate() # returns True

DFA.copy(self)

dfa.copy() # returns deep copy of dfa

DFA.minify(self)

Creates a minimal DFA which accepts the same inputs as the old one. Unreachable states are removed and
equivalent states are merged.

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

minimal_dfa = dfa.minify()

DFA.from_nfa(cls, nfa)

Creates a DFA that is equivalent to the given NFA.

from automata.fa.dfa import DFA

from automata.fa.nfa import NFA

dfa = DFA.from_nfa(nfa) # returns an equivalent DFA

class NFA(FA)

The NFA class is a subclass of FA and represents a nondeterministic finite automaton. It can be found
under automata/fa/nfa.py .

Every NFA has the same five DFA properties: state , input_symbols , transitions , initial_state , and final_states .
However, the structure of the transitions object has been modified slightly to accommodate the fact that a single
state can have more than one transition for the same symbol. Therefore, instead of mapping a symbol
to one end state in each sub-dict, each symbol is mapped to a set of end states.

from automata.fa.nfa import NFA

# NFA which matches strings beginning with 'a', ending with 'a', and containing

# no consecutive 'b's

nfa = NFA(

states={'q0', 'q1', 'q2'},

input_symbols={'a', 'b'},

transitions={

'q0': {'a': {'q1'}},

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

# Use '' as the key name for empty string (lambda/epsilon) transitions

'q1': {'a': {'q1'}, '': {'q2'}},

'q2': {'b': {'q0'}}

},

initial_state='q0',

final_states={'q1'}

NFA.read_input(self, input_str)

Returns a set of final states the FA stopped on, if the input is accepted.

nfa.read_input('aba') # returns {'q1', 'q2'}

nfa.read_input('abba') # raises RejectionException

NFA.read_input_stepwise(self, input_str)

Yields each set of states reached as the NFA reads characters from the input string, if the input is accepted.

nfa.read_input_stepwise('aba')

# yields:

# {'q0'}

# {'q1', 'q2'}

# {'q0'}

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

# {'q1', 'q2'}

NFA.accepts_input(self, input_str)

if nfa.accepts_input(my_input_str):

print('accepted')

else:

print('rejected')

NFA.validate(self)

nfa.validate() # returns True

NFA.copy(self)

nfa.copy() # returns deep copy of nfa

NFA.from_dfa(cls, dfa)

Creates an NFA that is equivalent to the given DFA.

from automata.fa.nfa import NFA

from automata.fa.dfa import DFA

nfa = NFA.from_dfa(dfa) # returns an equivalent NFA

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

UNIT-1
MULTIPLE CHOICE QUESTIONS

1. Structured programming supports the concept of discarding _________ statement.


[CLO-1,L1]
A. Foreach B. Goto C.Inline D.Step (Ans:
B)
2. ______ is the world9s first programming language. [CLO-1,L1]
A. Plankalkul B.ALGOL C. C program D. ProLog(Ans: A)
3. ________ is the first successful high level programming language. [CLO-1,L1]

A.C Program b. Fortran c. COBOL D. Anime (Ans: B)

4. Which of the following is true regarding meta programming?[CLO-1,L2]


A. generates semantic associations
B. Programs about programs
C. generates higher-order programs
D. is used for assembly level manipulations(Ans: C)

5. Syntax of Variable-length arguments . [CLO-1,L2]

A (*arg) B.(arg)

C. (/arg) D.(#arg) (Ans A)

6 What will be the output of the following code?[CLO-1,L2]


a=1
while a==1:
print(<Hello World!=)

A)Hello is printed once B) Hello infinite number of times


C) Hello is not printed at all D) Exception is thrown
Ans B

7 Which of the following remarks about the differences between constructors


and destructors are correct ? [CLO-1,L1]
A.Constructors can take arguments but destructors cannot.
B.Constructors can be overloaded but destructors cannot be overloaded.

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

C.Destructors can take arguments but constructors cannot.


D.Both (a) and (b)

8 According to Bohm-Jacopini, a function is possible by combining subprograms in which


three manners? . [CLO-1,L1]
A. Jump, Sequence and Loop
B. Sequence, Function Calls and Subroutines
C. Sequence, Iteration and Selection
D. Iteration, Macros and Branching
(Ans:C)

9. print() is _________[CLO-1,L1]

A. Built-in function, B.anonymous ,


C.Predefined Funcion, D.Keyboard function
Ans:A

10.anonymous function means_____[CLO-1,L2]

A.Function to be defined without any name B.Function to be defined no arguments

C.Function to be defined class name D.Function to be defined object name

Ans:A

11.Predict the output of the following program: [CLO-1,L3]

def func(a=18, b=5, c=10):


print 'a is', a, 'and b is', b, 'and c is', c
func(3, 7)
A. 3,7,10 B.5,10,7
B. 5,9,1 D.5,10,3

12.Which of the following is not a basic control structure? [CLO-1,L1]


A. Process
B. Decision
C. Loop
D. Sequential

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

(Ans:A)

13.Identify the arguments from the following piece of code. [CLO-1,L3]


def greet(name,msg):
print("Hello",name + ', ' + msg)
greet("Monica","Good morning!")
A. name, msg B."Hello",name + ', ' + msg
C. Monica, Good morning D. name, Monica
(Ans:C)
14.Identify a procedure call from the following snippet [CLO-1,L2]
A. n=input (n) B. f=input(n) C. input(n) D. f=n
(Ans: C)
15.When will an infinite loop error occur? [CLO-1,L1]
A. When the body of the loop has a static variable
B. when the body of the loop doesn9t change the test condition
C. When the body of the loop affects the test condition
D. When the test condition fails

(Ans: B)

16.Structure Programming supports what kind of Approach? [CLO-1,L2]


A.Bottom up B.Top Down

C.Single Approach D.None of these

(Ans: B)

17.Predit the output[CLO-1,L3]

class Parent:
def func1(self):
print("this 1")
class Parent2:
def func2(self):
print("this 2")
class Child(Parent , Parent2):
def func3(self):
print("this 3")
ob = Child()

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

ob.func1()
ob.func2()
ob.func3()

A.this 1,this 2,this 3 B.this 2,this 2,this 3

C.this 31,this 2,this 3 D.this is 1,this 2,this 2

(Ans:A)

18Which keyword is used for creating Class in Python?[CLO-1,L1]


A. Class B. Define
C. def D. Function

Ans A

19.Which of the following is correct output of this program? [CLO-1,L3]


def my_sum(*args):
return sum(args)
print(my_sum(1, 2, 3))
print(my_sum(1, 2, 3, 4, 5, 6, 7, 8))

A.6,36 B.36,36
C 11,10 D.15,10
Ans:A

20.What does the following code print to the console?[CLO-1,L3]


if 5 > 10:
print("fan")
elif 8 != 9:
print("glass")
else:
print("cream")

A. Fan B. glass C. cream D. glass cream

(Ans: C)

21.Which one of the following is the correct way of calling a function? [CLO-1,L2]

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

A. function_name() B. call function_name()

C. ret function_name() D. function function_name()

Ans:D

22.What will be the output of the following code?[CLO-1,L3]

def outerFun(c,d):
def innerFun(e, f):
return e + f
return innerFun(c, d)
return c
result = outerFun(10, 5)
print(result)

A..10 B.error C.10 d.15


Ans:A
23.What is the output of the following code?[CLO-1,L3]

def f():
global s
print s
s = "Python Section"
print s
# Global Scope
s = "Python is great!"
f()
print s
A.Python section Python is great B. Python section Python section
C. Error: local variable 8s9 referenced before assignment
D.Python is great Python section
(Ans: D)

24.How to Create a function named my_function. [CLO-1,L3]

---------

print("Hello from a function")

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

A. def my_function() B. my_function()


C. def myfunction() D.def My_function();

Ans:A

25.If you do not know the number of keyword arguments that will be passed into your function,
there is a prefix you can add in the function definition, which prefix? [CLO-1,L3]

def my_function(-----kid):

print("His last name is " + kid["lname"])

A.*** B**

C.**/ D.&**

Ans B

26.What is the correct syntax to create a class named Student that will inherit properties and
methods from a class named Person? [CLO-1,L2]

class -------------:

A.*Student(Person) B.//Student(Person)

C.Student(Person): D. Class Student(Person)

Ans D

27.We have used the Student class to create an object named x.

What is the correct syntax to execute the printname method of the object x? [CLO-1,L3]

class Person:

def __init__(self, fname):

self.firstname = fname

def printname(self):

print(self.firstname)

class Student(Person):

pass

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

x = Student("Mike")

------------------

A.x.printname() B.x.PrinName();

C.x.printfname() C.x(printname());

Ans: A

28.What is the correct syntax to import a module named "mymodule"?[CLO-1,L1]

-------------- mymodule

A.import B.include

C.inheret D.insert

Ans A

29.Display the sum of 5 + 10, using two variables: x and y. [CLO-1,L3]

-------=-----
y = 10
print(x y)
A.x=5 B.x=10

C.y=5 D.x=y

Ans A

30.The following code example would print the data type of x, what data type would that be?
[CLO-1,L3]

x = "Hello World"

print(type(x))

-----------

A.str* B. <class 'str'>

C.string D.strs

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

Ans B

31.The following code example would print the data type of x, what data type would that be?

x = ["apple", "banana", "cherry"][CLO-1,L2]

print(type(x))

A.list B.print

C.int D.str

Ans A

32.Use the len method to print the length of the string. [CLO-1,L3]

x = "Hello World"

print(---------(x))

A.length B.len

C.lan D.long

Ans B

33.Python is a popular programming language. It was released in----------[CLO-1,L1]

A.1991 B.1998

C.1992 D.1990

Ans A

34.---------------- refers to the spaces at the beginning of a code line. [CLO-1,L1]


A.Indentation B.input

C.Inherit D.identification

Ans A

35.Insert the missing part of the code below to output --------"Hello World".[CLO-1,L1]
A.Print("Hello World") B.Print f("Hello World")

C.Print("Hello "): D.Printf("Hello World"):

Ans A

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

36.How do you insert COMMENTS in Python code? [CLO-1,L2]

A./*This is a comment*/ B./*This is a comment*/


C./*This is a comment*/ D.#This is a comment
Ans D
30.What is the correct way to create a function in Python? [CLO-1,L2]

A.Function myfunction(): B.def myFunction()


C.Create myFunction(): D.def myFunction():
Ans: D

37.Use the p1 object to print the value of x: [CLO-1, L3]


class MyClass:
x=5
p1 = MyClass()
print(-------)
A.p1(x) B. p1.x
C.p1*x D. p1.x;
Ans B
38. How many independent objects can be returned at same time from a function?[CLO-1,L1]
A) 1 B) 2
C) 3 D) 4
(Ans: A)
39.Identify the option that represents call by value .[CLO-1,L2]
Int a=10, b=20;
A,Swap(&a,&b) B.Swap(a,b)
C,Swap(*a,*b) D.Swap()
(Ans: B)
40.Which keyword is used for function in Python?[CLO-1,L1]
A) Fun B) Define
C) def D) Function
(Ans: C)

41.Which of the following Items are present the function header?[CLO-1,L1]


A. function name only B. function name and parameter list
C. parameter list only D. return value
(Ans: B)

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

42.What is the output of the following? [CLO-1,L3]

x = "abcdef"
i = "i"
while i in x:
print(i, end=" ")
A)no output B) i i i i i i … c) a b c d e f D) abcdef
(Ans:A)

43. Objects are data structures that contain _______[CLO-1,L1]


A.Variables and properties B.Indexes and attributes
C.Attributes and operations D.Only attributes
(Ans: C)

44. Which of the following best defines a class?[CLO-1,L2]


A) Parent of an object B) Instance of an object
C) Blueprint of an object D) Scope of an object

45.If a function can perform more than 1 type of tasks, where the function name remains same,
which feature of OOP is used here?[CLO-1,L1]
A) Encapsulation B) Inheritance
C) Polymorphism D) Abstraction
(Ans:C)
46Which access specifier is usually used for data members of a class?[CLO-1,L1]
A) Private B) Default
C) Protected D) Public
(Ans:D)
47.Which specifier should be used for member functions of a class to avoid
inheritance?[CLO-1,L1]
A) Private B) Default
C) Protected D) Public
(Ans: A)

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

48.Which among the following best defines abstraction?[CLO-1,L2]


A) Hiding the implementation B) Showing the important data
C) Hiding the important data D) Hiding the implementation and showing only the features
(Ans: D)
50. How the constructors and destructors can be differentiated?[CLO-1,L1]
A) Destructor have a return type but constructor doesn9t
B) Destructors can9t be defined by the programmer, but constructors can be defined
C) Destructors are preceded with a tilde symbol, and constructor doesn9t
D) Destructors are same as constructors in syntax
(Ans:C)

51.-----comprises both data members and methods

A.Class B.Instance
C.Field D.Data
Ans A
PART B: 4 marks:
1. Write notes on the sub-fields of study under Programming language theory [CLO-1,L-1]
2. Write a python program with an add() function to return the sum of two integers.
[CLO-1,L-3]
3. Write a python program to generate factorial of 8n9 numbers.[CLO-1,L-3]
4. Write a python program to check palindrome using python procedure.[CLO-1,L-3]
5. What is structured programming? How does it minimize the complexity? [CLO-1,L-1]
6. Summarize the ways in which statements within a specific control structure are executed
[CLO-1,L-2]
7. List the verbal Guidelines of structured programming [CLO-1,L1]
8. Compare structured programming and Procedural programming [CLO-1,L-2]
9. Outline the working of bounded iteration with Python code snippets. [CLO-1,L2]
10. Write a program to create list and print the values. (CLO-1, L4)
11. Elaborate on Variables and its types(CLO-1, L2)
12. Write a program to implement constructors and destructors(CLO-1, L1)
13. What are the Functions declaration used in procedural programming language ? Give
example (CLO-1, L1)

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

14. Write the program to implement recursion.(CLO-1, L1)


15. Write a program to implement Fibonacci series using python. (CLO-1, L3)
16. Write down the basic Steps to design a Class.
17. Write a program to check prime numbers using class and objects.(CLO-1, L3)
18. Define Encapsulation. List any two of its advantages(CLO-1, L1)
19. What is Data abstraction and explain its types(CLO-1, L1)(CLO-1, L2)
20. Define Inheritance(CLO-1, L1)

PART C: 12Marks:

1. There are 50 computers available in computer programming lab where each computers
are used six hours per day. Write a Python program using classes and objects that contain
getDetail() for getting input from user,calculatesecondperDay() for calculating the usage
of each computer in seconds per day, calculateminutesperWeek() for calculating the
usage of each computer in minutes per week ,calculatehourperMonth() for calculating
usage of each computer in hour per month and calculatedayperYear() for calculating
usage of each computer in day per yearList all the Components of structured
programming language (CLO-1, L3)
2. Write a python program to create three classes namely, rectangle, square and cube to find
the area and perimeter, using classes and objects.(CLO-1, L3)
3. Develop a python program that get the student details such as student id, student name in
class student and get the mark1, mark2 in class subject. Create a new class result and
inherit the properties from student and subject class. Display all the details from result
class(CLO-1, L3)
4. Explain in detail about Control structures of structured programming language (CLO-1,
L5)
5. (a)Write a python program to create list, dictionary and tuple and access all three items
using while and for loop (CLO1-L3)
(b)Write a program to implement bubble sort. (CLO1-L3)
6. Explain in detail Structured programming in Python(CLO-1, L1)
7. Discuss the features of procedural programming(CLO-1, L6)

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

8. Define Function and recursion and explain them in detail (CLO-1, L1)(CLO-1, L2)
9. List out the Features of object oriented programming(CLO-1, L4)
10. Define Data abstraction and list out its types in detail (CLO-1, L1)(CLO-1, L4)
11. Write a python program to get square and cube of a number using inheritance
concept.(CLO1-L3)

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

UNIT-2

MULTIPLE CHOICE QUESTIONS

1. In event driven programming, flow of the program is determined by ____[CLO2-L1]


a. Sensors only
b. Exceptions and Errors only
c. User actions and sensors
d. Peripherals only
(Ans:c)
2. Which of the following languages does not support Event-driven programming
paradigm? [CLO2-L1]
a. ALGOL B. Python c. Javascript d. Prolog
(Ans:d)
3. Which of the following is not an Event? [CLO2-L2]
a. User actions b. System messages c. Interrupts d. Compiler Errors
(Ans:d)
4. What does the scheduler do when an event occurs? [CLO2-L2]
a. Throw an Exception
b. Call the appropriate event handler
c. Terminate the program
d. Wait for the event to be handled
(Ans:b)
5. Which of the following is not true about an event handler? [CLO2-L3]
a. Block of code that deals with an event
b. Triggered by an event
c. One event can have only one handler
d. Executes only when it is called
(Ans: c)
6. Identify the participants in an event: [CLO2-L1]

a. Source of the event, Event, Event handler

b. Source of the event, Event, Exception

c. Source of the event, Event, Notification, Event handler

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

d. source of the event, Event handler, Messages

(Ans: a)

7. Once the event is processed, the program returns from the event handler to the
___________ to look for the next event.[CLO2-L1]
a. DUI application b. event handle loop c. event dispatch loop d. event schedule
loop
(Ans:c)
8. Event handler is also known as __________________ [CLO2-L1]
a. Event Procedure
b. Event Listener
c. Event Dispatcher
d. Event Scheduler
(ANs: B)
9. Identify the top-level window with a title and a border [CLO2-L2]
a. JWindow b. JFrame c. JDialog d. JPop
(Ans:b)
10. A tooltip is a [CLO2-L2]
a. Dialog box that helps in determining a process
b. Window, which gives brief information about an object.
c. Popup that notifies the user about events
d. None of the above
(Ans:b)
11. Which of the following command is used to create a tooltip? [CLO2-L2]
a. panel.setToolTipText(text)
b. panel.fixToolTip(coordinates)
c. panel.setToolTip(coordinates)
d. panel.setToolTipFrame(text)
(Ans:a)
12. Which of the following method is used to set the position of any component in a
frame? [CLO2-L2]
a. setBounds(a,b,c,d)
b. setPosition(a,b,c,d)
c. setBoundary(a,b,c,d)

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

d. setFramePos(a,b,c,d)
(Ans:a)
13. What does the method setVisible(true) do? [CLO2-L1]
a. Closes all other windows on screen
b. Displays the frame on screen
c. Displays all available frames on screen
d. Closes the window after inactivity
(Ans:b)
14. Identify the command that creates a PyQT label? [CLO2-L3]
a. label=PLabel(8Hello World9)
b. label=QLabel(8Hello World9)
c. label=new Label(8Hello World9)
d. label=JLabel(8Hello World9)
(Ans: b)
15. ________ command can be used to install Python packages externally [CLO2-L1]
a. Install b.init c.pip d.install pip
(Ans:c)
16. Which of the following is true about Bind function? [CLO2-L2]
i. Bind function binds Python methods to an event
ii. Bind function binds functions to a widget
a. i only b. ii only c.i,ii d.Both are false
(Ans:C)
17. In Tkinter , the main window is known as [CLO2-L1]
a. Master b. Root c. Primary d. JWindow
(Ans:b)
18. Tkinter uses _______ method to set the size of the widget [CLO2-L1]
a. setSize() b.setPosition c.geometry() d.setgeometry
(Ans:c)
19. When we bind keyboard buttons with the tkinter window, what action takes place
when special characters are pressed? [CLO2-L2]
a. New line is included
b. Whitespace is included
c. Some characters are displayed
d. Exception is thrown

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

(Ans:b)
20. Tk() requires which three names to be defined? [CLO2-L1]
a. RootName, UserName, ScreenName
b. ScreenName, BaseName, ClassName
c. WindowName, ClassName, ObjectName
d. WindowName, BaseName, ObjectName
(Ans:b)
21. What is not true about Declarative programming? [CLO2-L3]
a. focus is on what needs to be done rather how it should be done
b. style of building programs that expresses logic of computation without talking about its
control flow
c. declare the result we want rather how it has be produced
d. builds programs using implementation logic
(Ans:d)
22. Identify examples of declarative statements? [CLO2-L2]
a. Literals, variables, constants
b. Data types, functions, Macros
c. Variables, functions, constants
d. Constants, data types, methods
(Ans:a)
23. Which type of the declarative statements does the following code represent?
[CLO2-L3]

class MyClass:
x=5
y=’John’
p1 = MyClass()
print(p1.x)

a. Homogenous Declarative
b. Hybrid declarative
c. Heterogeneous declarative
d. Multiple Declarative

(Ans:a)

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

24. Object attributes are defined within the _________ constructor [CLO2-L2]
a. _init_
b. _initialize_
c. _attr_
d. _obj_
(Ans:a)
25. What are the object attributes in the following code? [CLO2-L3]
class Dog:
dogs_count = 0
def __init__(self, name, age):
self.name = name
self.age = age
print("Welcome to this world{}!".format(self.name))
Dog.dogs_count += 1
a. Dog, name, age
b. name, age
c. dogs_count, name, age
d. self, name, age, dogs_count
(Ans: b)
26. What does a descriptor protocol hold? [CLO2-L2]
a. methods that overload attribute access of descriptors
b. methods that override attribute access of descriptors
c. methods that define the attribute and variable access of descriptors
d. methods that declare the attributes of descriptors
(Ans:b)
27. Which among the following is not a part of the descriptor protocol? [CLO2-L3]
a. descr.__get__(self, obj, type=None) -> value
b. descr.__set__(self, obj, value) -> None
c. descr.__set__(self, obj, value) -> value
d. descr.__delete__(self, obj) -> None
(Ans:c)
28. What happens when an instance9s dictionary has an entry with the same name as a non-data
descriptor? [CLO2-L2]
a. the dictionary entry takes precedence

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

b. the non-data descriptor takes precedence


c. An Exception is thrown
d. the data descriptor takes precedence
(Ans:a)
29. How to make a read-only data descriptor? [CLO2-L2]
a. Define __get__() method alone
b. Define __get__() and __set__() methods with __get()__ raising an exception
c. Define __get__() and __set__() methods with __set()__ raising an exception
d. Declare __get()__ and define __set()__ methods
(Ans: c)
30. Which of the following is not true about a descriptor? [CLO2-L2]
a. a descriptor is an object attribute with <binding behavior=
b. If all the __get__(), __set__(), and __delete()__ methods are defined for an object,
it is said to be a descriptor
c. They are the mechanism behind properties, methods, static methods, class methods,
and super()
d. Descriptors simplify the underlying C-code and offer a flexible set of new tools
for everyday Python programs
(Ans: b)
31. How to prevent automatic descriptor calls? [CLO2-L1]
a. Invoke _ _getattribute()_ _
b. Override _ _getattribute()_ _
c. Overloading _ _getattribute()_ _
d. Declaring _ _getattribute()_ _
(Ans:b)

32. Which of the following is true regarding descriptors? [CLO2-L2]


a. data descriptors do not override instance dictionaries
b. overloading __getattribute__() prevents automatic descriptor calls
c. descriptors are invoked by the __getattribute__() method
d. A descriptor cannot be called directly by its method name
(Ans:c)

33. What is false regarding imperative languages? [CLO2-L2]

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

a. work by modifying program state


b. code executes too slowly for optimal results on complex data science applications
c. focus on what and not how
d. executes step by step commands
(Ans: c)
34. Which among the following is not a primitive data structure? [CLO2-L1]
a. Pointers
b. Files
c. Boolean
d. Integer
(Ans:b)
35. Which among the following is not a List in Python? [CLO2-L1]
a. Graphics
b. Stack
c. Array
d. Tree
(Ans:c)
36. Which among the following is false regarding Lists in Python? [CLO2-L2]
a. List in Python is the same as 8array9 in other languages
b. Python lists are heterogeneous, which means you can add any kind of value in a
list
c. List does not allow duplicate numbers.
d. List is a collection which is ordered and changeable.
(Ans:c)
37. Which is the right syntax to join two lists in Python? [CLO2-L2]
a. Listoflist = {listA},{listB}
b. listoflist = [listA, listB]
c. listoflist = [listA+listB]
d. listoflist = [listA]+[listB]

(Ans:b)

38. Which among the following is not true regarding Tuples? [CLO2-L2]
a. To access values in tuple, use the square brackets along with the index
b. Removing individual tuple elements is not possible
c. the tuples cannot be changed once created

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

d. tup2 = [1, 2, 3, 4, 5 ] creates a tuple 8tup29 with 5 elements


(Ans:d)
39. Identify the true statement about a Dictionary? [CLO2-L2]
a. A dictionary is an ordered collection
b. It cannot be changed once created
c. The items can be accessed using keys in square brackets
d. It can be initialized using keys and values inside square brackets
(Ans:c)
40. Which is the right syntax for copying a dictionary? [CLO2-L2]
a. mydict = thisdict.copyTo()
b. mydict = thisdict.copy()
c. mydict = new dict(thisdict)
d. dict2=dict1
(Ans:b)
41. Which among the following is not a part of Abstract Data Types interface? [CLO2-L1]
a. Constructors
b. Mutators
c. Iterators
d. Destructors
(Ans:d)
42. What is not a feature of Abstract Data Type? [CLO2-L2]
a. ADT allow us to focus on the use of the new data type instead of how it9s
implemented
b. ADT definition depends on their implementation.
c. Abstract data types can be viewed as black boxes
d. ADT is a data type that specifies a set of data values and a collection of
well-defined operation
(Ans:b)
43. Which of the following represents linear running time? [CLO2-L1]
a. O(1) b. O(n) c. O(cn) d. O(n log n)
(Ans:b)
44. What is not a basic criteria to select a data structure? [CLO2-L1]
a. Storage requirements
b. Data access and manipulation facility

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

c. Implementation of operations
d. Handling complexity
(Ans:d)
45. Identify the methods of Iterator class in Python? [CLO2-L2]
a. __iter__ and __next__
b. __repeat __ and __ iter__
c. __iter__ and __move__
d. __prev__ and __next__
(Ans:a)
46. States in Python are represented as [CLO2-L1]
a. Class
b. Variables
c. Objects
d. Static variables
(Ans:c)
47. Which of the following will modify a state? [CLO2-L3]
a. pass the name(s) of the state(s) to the Machine initializer
b. directly initialize each new State object
c. modify() method that belongs to the State object
d. pass a dictionary with initialization arguments

(Ans:c)

48. What is true about Callbacks in state? [CLO2-L2]


a. A state can be associated with only one entry or exit callback
b. Callbacks have to be mentioned during initialization only
c. Machine initializer gives methods that will allow the user to add callbacks later
d. Callbacks are not always called when the state machine leaves or enters the state.
(Ans:d)
49. The current state of the model can be checked by [CLO2-L2]
i. calling is_«state name»()
ii. inspecting the .state attribute
a. i is only true
b. ii is only true

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

c. Both are true


d. Both are false

(Ans:c)

50. Which transition will never leave the state? [CLO2-L1]


a. Internal transition
b. Reflexive transition
c. Iterative transition
d. Casted Transition
(Ans:b)
51. Which callback is executed immediately after the transition begins? [CLO2-L1]
a. Init
b. Prepare
c. Enter
d. Run
(ANs: b)
52. Which of the following is not a part of an INFO-level logging in Python? [CLO2-L2]
a. state changes
b. transition triggers
c. callbacks
d. conditional checks
(Ans:c)

53.Config() in Python Tkinter are used for

a) destroy the widget


b) place the widget
c) change property of the widget
d) configure the widget
Answer: c

54. What is the correct way to draw a line in canvas tkinter ?

a.line()

b.canvas.create_line()

c.create_line(canvas)

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

d.None of the above

Answer: b

55. fg in tkinter widget stands for ?

a.foreground

b.background

c.forgap

d.None of the above

Answer: a

56. How does the pack() function works on tkinter widget ?

a.According to x,y coordinate

b.According to row and column vise

c.According to left,right,up,down

d.None of the above

Answer: c

57. How does the grid() function put the widget on the screen ?

a.According to x,y coordinate

b.According to row and column wise

c.According to left,right,up,down

d.None of the above

Answer: b

58. How does the place() function put the widget on the screen ?

a.According to x,y coordinate

b.According to row and column vise

c.According to left,right,up,down

d.None of the above

Answer: a

59. How we import a tkinter in python program ?

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

a.import tkinter

b.import tkinter as t

c.from tkinter import *

d.All of the above

Answer: d

60. How do we install tkinter in system ?

a.pip install python

b.tkinter install

c.pip install tkinter

d.tkinter pip install

Answer: c

61. Screen inside another screen is possible by creating

a.Another window

b.Frames

c.Buttons

d.Labels

Answer: b

62. Which function is used to delete any widget from the screen ?
a.stop()
b.delete()
c.destroy()
d.break()

Answer: c

63. _____________ is the standard language used to communicate with a relational database

a. MySQL Server
b. SQL
c. MongoDB
d. MSAccess

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

answer: b

PART B: 4 marks:

1. List and define the three participants in an event [CLO2-L1]


2. Write down the basic steps to handle an event [CLO2-L2]
3. How is KeyListener used to handle keypress event? [CLO2-L3]
4. Why do we need Adapter class in Swing? Explain with example. [CLO2-L2]
5. Write a Python program that creates a Timer that will explode in 2 seconds using
TURTLE module. [CLO2-L3]
6. What are the common definitions of declarative programming and what are the
two major subparadigms? [CLO2-L1]
7. List the declarative statements in declarative programming with examples.
[CLO2-L1]
8. Write short notes on Descriptor Protocol and types of it. [CLO2-L1]
9. Write a class whose objects are data descriptors and which print a message for
each get or set in Python. [CLO2-L3]
10. Illustrate the invoking of a descriptor using _ _getattribute()_ _
method.[CLO2-L3]
11. Why do we need Descriptors? What are the methods to create it in Python?
[CLO2-L3]
12. What are the factors that decide the order in which the arguments are binded
during descriptor invocation? Give examples.[CLO2-L2]
13. Using Turtle, Write a Python program to demonstrate Keypress Events. the turtle
on the screen must move according to the arrow keys (Up,Left,Right and Back)
pressed. [CLO2-L3]
14. Write the essential features of imperative programming [CLO2-L2]
15. What are State objects in Python? How are they initialized and modified?
[CLO2-L2]
16. What is a Callback? Illustrate with a program as to how to attach a callback to a
state in Python? [CLO2-L2]

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

17. Write a Python program to create three states 8solid9, 9liquid9 and 9gas9 and
initialize them using Machine initializer. [CLO2-L3]
18. Write a Python program to create three states 8solid9, 9liquid9 and 9gas9 and add
an exit call back that prints 8Leaving [current] state9. (Eg: Leaving Liquid state)
[CLO2-L3]
19. What is a transition? What is the best way to initialize transitions? Give example.
[CLO2-L3]
20. Write a Python program that when the given states are ['A', 'B', 'C'], the valid
transitions will be A → B, B → C, and C → A (but no other pairs). [CLO2-L3]
21. List the primitive and non-primitive data types in Python and define their use.
[CLO2-L1]
22. Write a Python program to create a List 8ListA9 of six numbers (1-6), append (7)
to ListA and copy the entire list to ListB. Print ListB [CLO2-L3]
23. Bring out the differences between Lists and Tuples in Python using examples.
[CLO2-L3]
24. Explain about Dictionary in Python using an example [CLO2-L1]
25. Create a Dictionary that maintains Student Records as follows and print only the
2nd and 7th student Names.

Register Name
number

001 Adam

002 Bob

003 Cain

004 David

005 Elm

006 Foo

007 Gont

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

26. What are the categories of operations by which the user interacts with the
instances of ADT [CLO2-L2].
27. What are the basic criteria in selecting the right data structure for an Algorithm?
[CLO2-L2]
28. Compare and contrast imperative programming and declarative programming.
[CLO2-L3]
29. Write a function called add which takes in an array and returns the result of adding
up every item in the array. [add([1,2,3]) // 6] in both declarative and imperative
styles. [CLO2-L3]
30. List out the advantages of imperative programming and declarative programming.
[CLO2-L2]
31. Write the code snippet to read a file content in python using GUI
paradigm.[CLO2-L2]
32. Implement a graphical slider using python by giving the user the option of picking
through a range of values.[CLO2-L2]

PART C: 12 marks

1. Discuss about an Event object and steps to handle an event [CLO2-L1].


2. In a company worker efficiency is determined on the basis of a time required for a worker to
complete a specific job. If the time taken by the worker is between 2-3 hours, then the worker
is said to be highly efficient. If the time required by the worker is between 3-4 hours, then the
worker is ordered to increase their speed. If the time required by the worker is between
4-5hours, then the worker is given training to increase the speed. If the time taken is more
than 5 hours, then worker should leave the company. Get the <time taken= as the input from
the user and find the efficiency of the worker and also provide the suggestion according to the
efficiency. [CLO2-L3]
3. Design the Students information system with student details, qualification details and
mark details and add insert, delete and update button. Write an event handler to send
the marks to their parents, immediately after the mark has been updated.[CLO2-L3]
4. Design a rostering schedule application after getting the free hours,date , name, time
to be scheduled and conditions to be considered for making schedule. [CLO2-L3]
5. What is a keypress event? Illustrate the steps of handling it in Python. [CLO2-L2]
6. Write a Python Program to create two Turtles to handle Mouse Events (A,B) and
create separate event handlers for the two Turtles that will print the name of the Turtle
clicked. [CLO2-L3]

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

7. Elaborate on the features of declarative programming and list the set of declarative
statements. [CLO2-L1]
8. What are Descriptors? Explain with example on creating descriptors using Class
methods and property() method. [CLO2-L2]
9. Demonstrate the Lookup chain in Descriptors using Python. [CLO2-L3]
10. Write a Python program to create three states Solid, Liquid and Gas. Create transitions
Melt, Evaporate, Sublimate and Ionize with an exit callback printing the transition
name. [CLO2-L3]
11. Explain Queues Transition between states in Python with example. [CLO2-L2]
12. Explain with examples List, Tuples and Dictionaries in Python. [CLO2-L2]
13. Compare imperative programming with declarative programming. [CLO2-L1]
14. Write a Python program to Create Countdown Timer using Python Tkinter.
[CLO2-L3]
15. Write a python code to implement key events and mouse events.[CLO2-L3]

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

UNIT III

PART A: MULTIPLE CHOICE QUESTIONS

1. In programming, a series of logically ordered steps that lead to a required result is called ------------------
(CLO-3,L1)
a) compiler b) a program c) a data structure d) an algorithm
Ans:d
2.Which mechanism provides control to the program (CLO4-L2)

a)Unifier b)Automatic backtracking c)substitution d)declarative semantic

Ans:b

3._______ provides the values to the variables (CLO4-L1)

a)General unifier b)Automatic backtracking c)substitution d)declarative semantic

Ans:a

4. Logic programming language is a_________ (CLO4-L1)

a)non-procedural b) predicate c)declarative semantics d) clauses

Ans:a

5. Which supplies the basic form of communication to the computer(CLO4-L2)

a)predicate b)predicate calculus c)clauses d)semantics

Ans:b

6.________ is the set of predicate symbols together with their arties(CLO4-L1)

a)clauses b)predicate c)resolution d)predicate signature

Ans:d

7. In logic programming, the classes of formulae are called ________ (CLO4-L1)

a)logical connectives b)resolution c)clauses d) automic formulae

Ans:c

8.Special inference rule is called as ________ (CLO4-L1)

a)logical connectives b)resolution c)clauses d) automic formulae

Ans:b

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

9. A restricted version of the concept of the clause ________(CLO4-L1)

a)definite clause b)resolution c)clauses d) automic formulae

Ans:a

10.Sequence of clauses are called as ________ (CLO4-L1)

a) definite clause b) resolution c)prolog program d) logical connectives

Ans:c

11. --------- is a sequence of atoms (CLO4-L1)

a) definite clause b) resolution c)prolog program d)query

Ans:d

12. _____ represents an entity in the real world with its identity and behavior. (CLO-3,L1)
a) A method
b) An object
c) A class
d) An operator

Ans:b

13.What is setattr() used for?( CLO-3,L1)


a) To access the attribute of the object
b) To set an attribute
c) To check if an attribute exists or not
d) To delete an attribute

Ans:b

14. ___del___ method is used to destroy instances of a class. (CLO-3,L1)


a) True
b) False

Ans:a

15. Which keyword is used to define methods in Python? (CLO-3,L1)


(a) function
(b) def
(c) method
(d) All of these
Ans:B

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

16. Python allows string slicing. What is the output of below code :( CLO-3,L3)

s='cppbuzz chicago'
print(s[3:5])
a)pbuzz
b) buzzc
c) bu
d) None of these
Ans:c

17. What is correct syntax to copy one list into another? (CLO-3,L3)
(A) listA = listB[]
(B) listA = listB[:]
(C) listA = listB[]()
(D) listA = listB
Ans:B

18. Find the solution in python(CLO-3,L3)

a = 8.6
b=2
print a//b
a)4.3
b) 4.0
c) 4
d) compilation error
Ans:b

19. Which statement is correct....??( CLO-3,L1)

(a) List is mutable && Tuple is immutable


(b) List is immutable && Tuple is mutable
(c) Both are Immutable
(d) Both are Mutable.

Ans:a

20.What is the maximum possible length of an identifier? (CLO-3,L1)


(a) 32 characters
(b) 63 characters

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

(c) 79 characters
(d) None of the above
Ans:d

21.Which one of the following is not a python's predefined data type? (CLO-3,L1)
(A) Class
(B) List
(C) Dictionary
(D) Tuple
Ans:a

22. Functional programming is a declarative type of programming style. Its main focus is on
___________________ in contrast to an imperative style. CLO-3,L3)
a.what to solve
b.how to solve
c.when to solve
d.where to solve
Ans:a

23. Programming Languages that support functional programming: (CLO-3,L1)


a. Haskell
b. C
c.C#
d.Java
Ans:a

24.Functional programming uses __________________ (CLO-3,L1)


a.Mutable data
b.Immutable data
c.Bind data
d.meta data
Ans:b

25. Pure functions act on their ________________ (CLO-3,L1)


a. parameters
b.objects
c.Classes
d.Methods
Ans:a

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

26. A ________ node acts as the Slave and is responsible for executing a task assigned to it by the JobTracker.
(CLO-3,L1)
a) MapReduce
b) Mapper
c) TaskTracker
d) JobTracker
Ans:c

27. Point out the correct statement. (CLO-3,L1)


a) MapReduce tries to place the data and the compute as close as possible
b) Map Task in MapReduce is performed using the Mapper() function
c) Reduce Task in MapReduce is performed using the Map() function
d) All of the mentioned
Ans:a

28. Identify the function that is responsible for consolidating the results produced by each of the Map()
functions/tasks.( CLO-3,L3)
a) Reduce
b) Map
c) Reducer
d) All of the mentioned
Ans:a

29. Although the Hadoop framework is implemented in Java, MapReduce applications need not be written in
____________( CLO-3,L4)
a) Java
b) C
c) C#
d) None of the mentioned
Ans:a

30. __________ maps input key/value pairs to a set of intermediate key/value pairs. ( CLO-3,L3)
a) Mapper
b) Reducer
c) Both Mapper and Reducer
d) None of the mentioned
Ans:a

31. The number of maps is usually driven by the total size of ____________ (CLO-3-L1)
a) inputs

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

b) outputs
c) tasks
d) None of the mentioned
Ans:a

32. Point out the wrong statement. (CLO3-L1)


a) A MapReduce job usually splits the input data-set into independent chunks which are processed by the map
tasks in a completely parallel manner
b) The MapReduce framework operates exclusively on <key, value> pairs
c) Applications typically implement the Mapper and Reducer interfaces to provide the map and reduce methods
d) None of the mentioned

Ans:d

33. What will be the output of the following Python code?( CLO-3,L3)

l-[-2,4]

m=map(lamda x:x*2,l)

print(m)

a)[-4, 16]
b) Address of m
c) Error
d)0

Ans:b

34. Which of the following numbers will not be a part of the output list of the following Python code?
(CLO-3,L3)

def sf(a);
return a%3!=0 and a%5!=0
m=filter(sf,range(1,31))
print(list(m))
a) 1
b) 29
c) 6
d) 10

Ans:d

35. What will be the output of the following Python code?( CLO-3,L3)

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

import functools
l=[1, 2, 3, 4, 5]
m=functools.reduce(lambda x, y:x if x>y else y, l)
print(m)
a) Error
b) Address of m
c) 1
d) 5

Ans:d

36. Partial functions allow us to fix a certain number of ____________of a function and generate a new function.
(CLO-3,L1)

a. arguments

b.parameters

c.both a and b

d.none of the above

Ans:c

37. In Python, value of an integer is not restricted by the number of ______( CLO-3,L1)

a.bytes

b.bits.

c.characters

d.strings

Ans:b

38.What is the use of ord()?(CLO-3,L3)

a. convert integer to octal string.

b. convert integer to hexadecimal string.

c. convert a character to integer.

Ans:c

39. Clojure is based on which programming language? (CLO-3,L1)


a.Ruby
b.Lisp
c.Python
d.PHP

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

Ans:Lisp

40. Which of these platforms is not used to run Clojure?( CLO-3,L2)


a.Java Virtual machine
b.Common language runtime
c.HTML
d.Javascript
Ans:C

41. Who designed Clojure? (CLO-3,L1)


a. Rich Hickey
b.James Borderman
c.Huateng Xue
d.Jerry Clojure
Ans:a

42. Which of these is not a file extension for Clojure? (CLO-3,L1)


a.ens
b.edn
c.cljs
d.clj
Ans:b

43. Which of the following does Clojure use? (CLO-3,L1)


a.Positive integers
b.Albhabets
c.Negative integers
d.0 and 1
Ans:a

44. How many types of Clojure maps exist? (CLO-3,L1)


a.1
b.2
c.3
d.4
Ans:2

45. Haskell lends itself well to ____________due to its explicit handling of effects. (CLO-3,L3)
a.functional programming
b. concurrent programming

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

c.shell programming
d.Procedural Programming
Ans:b
46. Open source contribution to Haskell is very active with a wide range of packages available on the public
package servers.( CLO-3,L3)
a.True
b.False
Ans:a

47. Haskell also is used in web startups where functional programming might work better than
____________________ (CLO-3,L1)
a.shell programming
b.functional programming
c. concurrent programming
d. imperative programming
Ans:d

48. which is a polymorphically statically typed, lazy, purely functional language?( CLO-3,L1)
a.Ruby
b.R language
c.Python
d.Haskell

49. Haskell is based on the lambda calculus, hence the lambda we use as a logo.( CLO-3,L3)
a.True
b.False
Ans:True

50. Why C language is better than Haskell?( CLO-3,L1)


a. Storage management
b. Performance
c. Time Complexity
d. Space Complexity
Ans:a

PART B:(4 MARKS)


1. Write the characteristics of logic programming. (CLO4-L1)

2. Write a program to perform arithmetic operations using logic programming. (CLO4-L3)

3. Write a program to derive n-parasitic number using logic programming. (CLO4-L3)

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

4. Explain logic symbols in detail. (CLO4-L1)

5. Write about non- logical symbols. (CLO4-L1)

6. Explain about predicate logic with example(CLO4-L1)

7. What is unification? Give example (CLO4-L1)

8. Differentiate clauses and resolution(CLO4-L2)

9. What is <term=? Give Example(CLO4-L1)

10. Compare clause and definite clause(CLO4-L2)

11. Give example for substitution(CLO4-L2)

12. Write a program to check prime numbers using python logic programming(CLO4-L3)

13. Contrast Python with other languages. (CLO-3, L3)


14. State Functional programming paradigm (CLO-3, L1)
15. Define Sequence of commands with respect to Functional Programming paradigm.
(CLO-3, L1)
16. Using map(), filter(), reduce(), develop a code that create a list of (n) **2 for range (10) for even integers.
(CLO-3, L3)
17. Why do lambdas defined in a loop with different values all return the same result? ( CLO-3, L2)
18. How to implement a function with output parameters(call by reference)?( CLO-3, L2)
19. Develop a sample code for reduce() function. (CLO-3, L3)
20. List what are the benefits of Haskell expression? (CLO-3, L1)
21. Explain the type system for Haskell? (CLO-3, L1)
22. Differentiate between Haskell (++) and (:)?(CLO-3, L2)
23. Why does Clojure not have user-extensible reader macros? (CLO-3, L2)
24. How do you achieve encapsulation with Clojure? (CLO-3, L2)
25. What is the unit type in F#? Implement the sample code. (CLO-3, L3)
26. Develop a sample using lambda expression in F#. (CLO-3, L3)
27. Describe Referential Transparency with an example in Python (CLO-3, L2)

PART :C (12 MARKS)

1. Write a logic programming to solve the following Zebra puzzle using python. (CLO4-L3)

There are five houses.


The English man lives in the red house.
The Swede has a dog.
The Dane drinks tea.
The green house is immediately to the left of the white house.
They drink coffee in the green house.
The man who smokes Pall Mall has birds.

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

In the yellow house they smoke Dunhill.


In the middle house they drink milk.
The Norwegian lives in the first house.
The man who smokes Blend lives in the house next to the house with cats.
In a house next to the house where they have a horse, they smoke Dunhill.
The man who smokes Blue Master drinks beer.
The German smokes Prince.
The Norwegian lives next to the blue house.
They drink water in a house next to the house where they smoke Blend.

2. Write a program to implement First Order Logic.(CLO4-L3)


3. Design a expense tracker that is used to keep track of the user’s expenses. It has to give correct information to
the users on their expenses and help them spend better using PySimpleGUI and PyData libraries.
4. Write a program to compare the following expressions and find the unknown value
(a) 16X3 + 8X2 + 15X +17
(b) 25X3 + 18X2 + 30X +165
5. Compare resolution and clauses. Explain in detail the same with examples.(CLO4-L2)
6. What is unification? Explain with example.(CLO4-L1)
7. Illustrate the prolog features with examples.(CLO4-L3)
8. Design a simple calculator using python programming.(CLO4-L3)

Create a module named My Triangle that contains following two functions.(a). Returns true if the sum of any two
side is greater than third side. (b) Returns the area of triangle. Write a test program that reads three sides for a
triangle and computes the area if the input is valid. Otherwise, it displays the input is invalid. (CLO-3, L3)

9. Write a python function named ack to evaluate the Ackermann function. Use your function to evaluate ack(3,4)
that should be 125. (CLO-3, L3)
10. What are the various ways of creating lists in Haskell? Explain. (CLO-3, L1)
11. What are the types of operators available in F#? Explain each with an example.( CLO-3, L1)
12. How Do we Create a Clojure Project? List the steps and explain. (CLO-3, L2)
13. Develop a partial function metadata with functool.update_wrapper().CLO-3, L3)
14. Partial functions are self-documented.Justify with example .( CLO-3, L3)
15. How long can lamda function excute? Explain. (CLO-3, L2)
16. Compare Concurrent programming paradigm and functional programming paradigm with example program.
(CLO-3, L2)
17. Develop an application using map(),filter() and reduce() functions. (CLO-3, L3)
18. Write a program in Python to show the use of Higher-Order functions. (CLO-3, L3)

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

UNIT 4

Dependent Programming paradigm, parallel and concurrent Programming paradigm

1. Parallelism representation is critical to the success of ---------------------- (CLO-4,L1)

a)High-performance computing.b)Low-performance computing

c)Scaling d)Vectorization

Ans:a

2. Parallel programming through a combination of -----------and ------------(CLO-4,L1)

a.Patterns, examples

b.Algorithms , flowcharts

c.Models , methods

d.Classes ,objects

Ans:a

3.What is multithreaded programming? (CLO-4,L1)

a) It’s a process in which two different processes run simultaneously

b) It’s a process in which two or more parts of same process run simultaneously

c) It’s a process in which many different process are able to access same information

d) It’s a process in which a single process can access information from many sources

Ans:b

4. Which of these are types of multitasking? (CLO-4,L2)

a) Process based

b) Thread based

c) Process and Thread based

d) None of the mentioned

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

Ans:c

5.What will happen if two thread of the same priority are called to be processed
simultaneously? (CLO-4,L2)

a) Anyone will be executed first lexographically

b) Both of them will be executed simultaneously

c) None of them will be executed

d) It is dependent on the operating system

Ans:d

6. Which of these statements is incorrect? (CLO-4,L2)

a) By multithreading CPU idle time is minimized, and we can take maximum use of it

b) By multitasking CPU idle time is minimized, and we can take maximum use of it

c) Two thread in Java can have the same priority

d) A thread can exist only in two states, running and blocked

Ans:d

7. Identify the technique that allows more than one program to be ready for execution and
provides the ability to switch from one process to another. (CLO-4,L2)

a) multitasking

b) multiprocessing

c) multitasking

d) multiprogramming

Ans:d

8. The technique that increases the system’s productivity. (CLO-4,L1)

a) multiprogramming

b) multitasking

c) multiprocessing

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

d) single-programming

Ans:a

9. _____________is a property which more than one operation can be run simultaneously but it
doesn’t mean it will be. (CLO-4,L1)

a. Concurrency

b.Semaphore

c.Mutual exclusion

d.parallel process

Ans:a

10.____________ is a light-weight cooperatively-scheduled execution unit.(CLO-4,L3)

a. gevent.Greenlet

b. gevent.spawn()

c.gevent.spawn_later()

d.gevent.spawn_raw()

Ans:a

11. Which keyword is used to define methods in Python? (CLO-4,L2)

(a) function
(b) def
(c) method
(d) All of these

Ans:B

12. What is the correct translation of the following statement into mathematical logic? <Some
real numbers are rational= .(CLO-4,L3)

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

Ans: c

13. Which one of the following options is CORRECT given three positive integers x, y and z, and a
predicate? .(CLO-4,L3)

P(x) = ¬(x=1)'∀y(∃z(x=y*z)⇒(y=x)((y=1))

P(x) being true means that x is a prime number

P(x) being true means that x is a number other than 1

P(x) is always true irrespective of the value of x

P(x) being true means that x has exactly two factors other than 1 and x

Ans: a

14. Suppose the predicate F(x, y, t) is used to represent the statement that person x can fool
person y at time t. which one of the statements below expresses best the meaning of the
formula ∀x∃y∃t(¬F(x, y, t))? .(CLO-4,L3)

(a) Everyone can fool some person at some time

(b) No one can fool everyone all the time

(c) Everyone cannot fool some person all the time

(d) No one can fool some person at some time

Ans: b

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

15. Which one of the following is the most appropriate logical formula to represent the
statement? <Gold and silver ornaments are precious=. (CLO-4,L3)

The following notations are used:

G(x): x is a gold ornament

S(x): x is a silver ornament

P(x): x is precious

(a) ∀x(P(x)→(G(x)'S(x)))

(b) ∀x((G(x)'S(x))→P(x))

(c) ∃x((G(x)'S(x))→P(x)

(d) ∀x((G(x)(S(x))→P(x))

Ans : d

16. Which one of the first order predicate calculus statements given below correctly express the
following English statement? .(CLO-4,L3)

Tigers and lions attack if they are hungry or threatened.

Ans: d

17. What is the first order predicate calculus statement equivalent to the following? (CLO-4,L3)

Every teacher is liked by some student

(A) ∀(x) [teacher (x) → ∃ (y) [student (y) → likes (y, x)]]

(B) ∀ (x) [teacher (x) → ∃ (y) [student (y) ^ likes (y, x)]]

(C) ∃ (y) ∀ (x) [teacher (x) → [student (y) ^ likes (y, x)]]

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

(D) ∀ (x) [teacher (x) ^ ∃ (y) [student (y) → likes (y, x)]]

Ans: b

18.

Which of the above two are equivalent? (CLO-4,L3)

(A) I and III

(B) I and IV

(C) II and III

(D) II and IV

Ans: b

19. ________is a builtin python module where all possible types are defined. .(CLO-4,L2)

(a) overload

b)typing

c)function

d)literal

Ans: b

20. ___________type represents a specific value of the specific type. .(CLO-4,L1)

a) overload

b) typing

c) literal

d) None of the above

Ans: c

21. __________ is required to define multiple function declarations with different input types
and results. .(CLO-4,L1)

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

a) overload

b) typing

c) literal

d) None of the above

Ans: a

PART B:(4 MARKS)


1. State parallel programming paradigm. (CLO-4, L1)

2. Differentiate parallel programming with functional programming. (CLO-4, L2)

3. Explain about Multithreading. (CLO-4, L1)

4. Explain about Multiprocessing. (CLO-4, L1)

5. Relate Serial processing concepts in Python. (CLO-4, L3)

6. Differentiate Serial Processing and Parallel Processing. (CLO-4, L3)

7. Demonstrate Multiprocessing module in Python. (CLO-4, L3)

8. Describe about Process class. (CLO-4, L2)

9. Design a Pool class in Python.(CLO-4, L3)

10. State Concurrent programming paradigm. (CLO-4, L1)

11. Compare multiprocessing and multitaking. (CLO-4, L2)

12.What are dependent functions ?(CLO4-L1)

13. Define typing module in dependent type programming? (CLO-4, L2)

14.Define dependent functions? (CLO-4, L2)

15.What is predicate logic? (CLO-4, L2)

16.Different types of quantifiers. (CLO-4, L1)

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

17.Explain Universal Quantifier and Existential Quantifier (CLO-4, L1)

18.Write some examples of Universal Qunatifier. (CLO-4, L2)

19 Define overload and literal in dependent type programming (CLO-4, L2)

20. Write the syntax for Existential Quantifier. (CLO-4, L2)

PART :C(12 MARKS)

1. Write a python program to implement producer consumer problem. (CLO-4, L3)

2. Implement the concept <Pool class= by importing a package pool. (CLO-4, L3)

3. Write a python program to implement dinning philosopher problem. (CLO-4, L3)

4. Explain the differences between multithreading and multiprocessing with example? (CLO-4,
L1)

5.Write a program to implement thread synchronization (CLO-4, L3)

6. Compare Concurrent programming paradigm and functional programming paradigm with


example program. (CLO-4, L2)

7. Explain in detail about dependent type programming .(CLO4-L1)

8. Write a python program to create Type aliases using typing module. . (CLO-4, L3)

9. Write a python program to check every key:value pair in a dictionary and check if they match
the name:email format using typing module. . (CLO-4, L3)

10. Write a python program to create new user defined type Student using typing module. .
(CLO-4, L3)

11. Write a python program for function dependent type using overload and literals . . (CLO-4,
L3)

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

UNIT V
PART A: MULTIPLE CHOICE QUESTIONS
Symbolic:
1. Which of the following is false about sympy? (CLO5-L1)
a. Sympy is a python library for symbolic mathematics
b. It requires external libraries for execution
c. It is an alternative to the systems like mathematica or maple
Ans: B
2. Symbols can now be manipulated using some of python operators using _____.(CLO5-L1)

A)+. B) && C) ? D$

Ans: A

3. Which of the following belongs to the numerical type of sympy (CLO5-L1)


a. Float
b. Integer
c. Decimal
d. Factorial
Ans: B
4. Choose the correct output for the following code?(CLO5-L2)
Import sympy as sym
a= sym.Rational(4,6)
print a
a. 6/4
b. 0.66
c. 4/6
d. 1.5
Ans: C
5. What is the output for the trigonometry function? (CLO5-L2)
Sym.expand(sym.cos(x+y),trig=true)
a. sin(x)*sin(y)+cos(x)*cos(y)
b. sin(x)*cos(y)+cos(x)*sin(y)
c. -sin(x)*sin(y) - cos(x)*cos(y)
d. -sin(x)*sin(y) + cos(x)*cos(y)
Ans: D
6. Differentiate the Sympy Expression using the syntax (CLO5-L1)
a. diff (var,func)
b. diff(func,var)
c. diff(expr,var)
d. diff(var,point)
Ans: B
7. SymPy is able to solve algebraic equations, in one and several variables using(CLO5-L1)

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

a. solveset()
b. series()
c. real()
d. limit()
Ans: A
8. Which of the following belongs to the calculus function? (CLO5-L1)
i. Limit
ii. Series
iii. Arithmetic
iv. Computation
a. Both i,ii
b. Both ii,iii
c. Both ii,iv
d. Both i,iii,iv
Ans: A
9. Choose the output for the following code? (CLO5-L2)
Limit (sin(x), x,0)
a. 0
b. 1
c. Infinite
d. Error
Ans: B
10. Which of the following is the correct output for the below given code? (CLO5-L2)
Sym.integrate(x**3, (x,-1,1)
a. 1
b. 3
c. 0
d. -1
Ans: C
11. Which of the following is the correct output for the below given code? (CLO5-L2)
x,y=sym.symbols(8x,y9)
A=sym.Matrix([[1,x],[y,1]])
Print A
a. Matrix ([[1,x], [y,1]])
b. Matrix ([[x,1],[1,y]])
c. Matrix ([[0,x], [y,0]])
d. Matrix ([[x,0],[0,y]])
Ans: A
12. Choose the output for the following code? (CLO5-L2)
Sym.solveset(x**4-1,x)
a. {1,-1,I,-I}
b. {-1,1,-I,I}
c. {0,1,I,-I}
d. {1,-1,-I,I}

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

Ans: B
13. Limit the Sympy Expression using the syntax (CLO5-L1)
a. limit (var,func,point)
b. limit(func,var,point)
c. limit(func,var)
d. limit(var,point)
Ans: B
14. Finite state machines are used for____(CLO5-L1)
a. Pseudo random test patterns
b. Deterministic test patterns
c. Random test patterns
d. Algorithmic test patterns

Ans:D

15. According to the given transitions, which among the following are the epsilon closures of q1 for
the given NFA? (CLO5-L3)
Δ (q1, ε) = {q2, q3, q4}
Δ (q4, 1) =q1
Δ (q1, ε) =q1
a. q4
b. q2
c. q1
d. q1, q2, q3, q4

Ans: D

16. Which of the following tuples order are correct for Deterministic Finite Automata (DFA)
(CLO5-L1)
a. (Q, S, d, q0, F)
b. (Q, S, d, F,q0)
c. (S,Q, d, q0, F)
d. (Q, S, q0, d, F)

Ans: A

17. NFA, is called as9non-deterministic9 because of :(CLO5-L1)


a. The result is undetermined
b. The choice of path is non-deterministic
c. The state to be transited next is non-deterministic
d. All of the mentioned

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

Ans: B

18. _______ is a class attribute defined by its source state and destination state. .(CLO5-L1)
a. LGPL
b. Scipy
c. Transition
d. State

Ans : C

19. Among the following which is used to define the behavior of what we want to achieve (CLO5-L1)
a. State
b. Automata
c. Transition
d. Machine

Ans: D

20. _________is a triplet consisting of two states and one command needed for the change of one
state to the other. .(CLO5-L1)
a. machine
b. Automata
c. State
d. Transitions

Ans:D

21. _________is a mathematical model of computation. .(CLO5-L1)


a. state machine
b. Automata
c. State
d. Transitions

Ans: A

22. Which of the following is correct among the following expressions? (CLO5-L2)
i.

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

ii.

iii.

a. Both i,ii
b. Both ii,iii
c. Both i,iii
d. All of the above

Ans: A

23. What kind of abstract machine can recognize strings in a regular set? (CLO5-L1)
a. DFA
b. NFA
c. PDA
d. None of the above

Ans: A

24. Which of the following statements is wrong? (CLO5-L1)


a. The language accepted by finite automata are the languages denoted by regular expressions
b. For every DFA there is a regular expression denoting its language
c. For a regular expression r, there does not exist NFA with L(r) any transit that accept
d. None of the above.

Ans: C

25. Let for ∑= {0,1} R= (∑∑∑) *, the language of R would be-------- (CLO5-L2)

a. {w | w is a string of odd length


b. {w | w is a string of length multiple of 3}
c. {w | w is a string of length 3}
d. All of the above.

Ans: B

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

26. (a+b)* is equivalent to------- (CLO5-L2)


a. b*a*
b. (a*b*)*
c. a*b*
d. None of the above.

Ans: B

27. In regular expressions, the operator 8*9 stands for------ (CLO5-L1)


a. Concatenation
b. Addition
c. Selection
d. Iteration

Ans: D

28. The regular expression with all strings of 0′s and 1′s with at least two consecutive 0′s is------
(CLO5-L2)
a. 1 + (10)* yh
b. (0+1)*011
c. (0+1)*00(0+1)*
d. 0*1*2*

Ans: C

29. Which of the following operation can be applied on regular expressions? (CLO5-L1)
a. Union
b. Concatenation
c. Closure
d. All of the above

Ans: D

30. Finite state machine will initially set to all zeroes. (CLO5-L1)
a. True
b. False

Ans: A

31. _______ allow millions of different machines, using all sorts of different network hardware, to
pass packets to each other over the fabric of an IP network.(CLO5-L1)
a)Sockets
b)Client machine
c)server machines

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

d)IP address
Ans: d
32. Which are all necessary to direct a packet to its destination.(CLO5-L2)
a)IP Address b)IP address and port c)port d)InternetAssignedNumbers
Ans:b
33. ________ (0–1023) are for the most important and widely-used protocols(CLO5-L1)
a. Well Known ports b)Registered ports c)Known ports d)Unregistered ports
Ans:a
34. ___________ (1024–49151) are not usually treated as special by operating systems(CLO5-L1)
a)Registered ports b)well known ports c)Known ports d)Unregistered ports
Ans:a
35. Python9s standard socket module supports _______(CLO5-L1)
a)getByName() b)getName() c)gethostbyname() d)getServName()
Ans:c
36. Example for Connection oriented protocol(CLO5-L1)
a)UDP b)SMTP c)FTP d)TCP
Ans:d
37. Example for Connection less protocol(CLO5-L1)
a)SMTP b) FTP c)UDP d)TCP
Ans:c
38. _________ is an application-level block of transmitted data.(CLO5-L1)
a)data b)datagram c)segmentation d)Fragmentation
Ans:b
39. Simple server uses ______ command to request a UDP network address.(CLO5-L1)
a)bind() b)scocket() c)getName() d)getsockName()
Ans:a
40. Which method is used by python program to retrieve the current IP and port to which the socket is
bound. (CLO5-L2)

a)bind() b)getsockname() c)getName() d)getSocket()

Ans:b
41. Sending packets with another computer9s return address is called ________(CLO5-L1)
a)Binding b) Unification c)Spoofing d) IP address
Ans:c
42. The concept by which larger UDP packets are spitted into several small physical
packets(CLO5-L1)
a)fragmentation b)Binding c) Unification d) partition
Ans:a
43. The MTU is _____ that all of the network devices between two hosts will support. (CLO5-L1)
a)smallest packet size b)medium packet size c)average packet size d)largest packet size
Ans:d
44. ______ is efficient only if your host ever only sends one message at a time, then waits for a
response.(CLO5-L1)
a)UDP b)TCP c)FTP d)SMTP
Ans: a
45. Which protocol provides reliable connection?(CLO5-L2)
a)UDP b) FTP c)TCP d)SMTP
Ans:c
46. TCP uses a ______ that counts the number of bytes transmitted.(CLO5-L1)
a) protocol b)counter c)rules d)Ports
Ans:b
47. The amount of data that a sender is willing to have on the wire at any given moment is called
____(CLO5-L1)
a) The size of the TCP window. b) counter c) port d) protocol

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

Ans:a

48. TCP uses _______ to distinguish different applications running at the same IP address, and
follows exactly the same conventions regarding well-known and ephemeral port
numbers.(CLO5-L1)
a) IP address b)port c)port numbers d) socket ID
Ans:c
49. _______refers to the address family ipv4.(CLO5-L1 (CLO5-L1)
a) Af_INET b) AS_INET c) AG_INET d) AN_INET
Ans:a
50. A server has a ______method which puts the server into listen mode.(CLO5-L1)

a)list() b)listento() c)listen() d)listenfrom()

Ans:c
51. ______ are the end-point of a two-way communication .(CLO5 L1) a)IP Address b)sockets
c)sockets ID d) Object ID
Ans:b

52. Identify the method used to connect the client to host and port and initiate the connection towards
the server.(CLO5-L3)
a)sock_object.recv() b)sock_object.send()
c)sock_object.append() d)sock_object.connect():
Ans:d
53. Identify the method to receive messages at endpoints when the value of the protocol parameter is
TCP.(CLO5-L3)

a)sock_object.recv() b)sock_object.send()
c)sock_object.append() d)sock_object.connect():

Ans:a

54. Which method is used to receive messages at endpoints if the protocol used is UDP.(CLO5-L2)
a)sock_object.recv() b)sock_object.recvfrom()
c)sock_object.append() d)sock_object.connect():

Ans:b
55. Identify the method that returns host name.(CLO5-L1)

a)sock_object.recv() b)sock_object.recvfrom()
c)sock_object.gethostname d)sock_object.connect():
Ans:c
56. Identify the method to send messages from endpoints if the protocol parameter is
UDP.(CLO5-L3)

a)sock_object.sendto(): b)sock_object.recvfrom()
c)sock_object.gethostname d)sock_object.connect():
Ans:a

57. ________can be used to end direction of communication in a socket(CLO5-L1)


a. The shutdown() call b)Shut() c)close() d)end()

Ans:c

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

PART: B (4MARKS)

1) Write a program to factorize the following expression. (CLO5-L3)


x**3 + 3*x**2*y + 3*x*y**2 + y**3
2) What is SymPy? (CLO5-L1)
3) Write the commands to perform the operations on substitutions and expressions
(CLO5-L1)
4) Design a DFA that accepts all strings that contain 010 or do not contain 0. (CLO5-L2)
5) Differentiate Finite state machine and Non deterministic Finite state machine. (CLO5-L2)
6) Let Σ = {0, 1}. Give DFAs for {}, {ε}, Σ*, and Σ+. (CLO5-L2)

7)
Provide the DFA function for the above-mentioned diagram (CLO5-L2)
8) Compare the features of LISP and Wolfram. (CLO5-L2)
9) Write a DFA automata code for L(M) ={ w | w has an even number of 1s} (CLO5-L2)
10) Write a DFA automata code for L(M)={(ab)n | n ∈ N}(CLO5-L2)
11) Construct NFA that recognizes the language of strings that end in 01 (CLO5-L2)
12) Find an NFA to recognize the language (a + ba)*bb(a + ab)*. (CLO5-L2)
13) Write the features of GUI programming. (CLO5-L1)
14) Explain briefly Automata based programming in python. (CLO5-L1)
15) Write the syntax for Expand and Factor command. Give example. (CLO5-L1)
16) Give example for DFA and explain. (CLO5-L2)
17) Differentiate Python and Jpython. (CLO5-L2)
18) Write the syntax for series and Integration command. Give example .(CLO5-L1)
19) Give example for NFA and explain. (CLO5-L1)
20) Differentiate TCP and UDP(CLO5-L2)
21) Compare connection oriented and connectionless service(CLO5-L2)
22) Differentiate automatic and manual configuration(CLO5-L2)
23) How will you generate random port numbers?(CLO5-L2)
24) What is file descriptors? Give example(CLO5-L1)
25) Differentiate bind() and getSockName() .(CLO5-L2)
26) What is UDP fragmentation? Give example .(CLO5-L1)
27) What will happen when you send large packets? Give example.(CLO5-L2)
28) Differentiate multicast and broadcast.(CLO5-L2)
29) Write the code to connect server and client in TCP.(CLO5-L3)
30) How does TCP provides reliable connection.(CLO5-L2)
31) Compare passive and active socket.(CLO5-L2)
32) Write the code to connect server and client in UDP.(CLO5-L3)

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

PART-C (12 MARKS)

1. Write a program to expand and factorize the following expression. (CLO5-L3)

a. x3 + 3x2y + 3xy2 + y3 = (x + y)3


b. x + y + x*y

2. Consider the following series:

X+(X2/2) + (X3/3) + (X4/4) +……+(Xn/N)

Write a python program that will ask a user to input a number, n, and print this series for that number.
In the series, x is a symbol and n are an integer input by the program9s user. The nth term in this series
is given as (Xn/N). (CLO5-L3)

3. Write a program to implement client server communication using UDP. (CLO5-L3)


4. Write a program to demonstrate the concept of UDP fragmentation and explain .(CLO5-L3)
5. Explain automata-based programming paradigm. (CLO5-L1)

6. Design go, slowdown and stop events according to the traffic scenario to cross the road using
python code and also draw transition diagram and transition table for the same scenario. (CLO5-L3)

7. Write a example program to find limits, differentiation, Series and Integration. (CLO5-L1)

8. Differentiate DFA and NFA. Explain NFA with example. (CLO5-L2)

9. Build an automaton that accepts all and only those strings that contain 001 (CLO5-L2)
10. Find an DFA for each of the following languages over the alphabet {a, b}.(CLO5-L3)

(a) {(ab)n | n ∈ N}, which has regular expression (ab)*.

b) Find a DFA for the language of a + aa*b.


11.a. Write NFA automata code for the Language that accepts all end with 01 (CLO5-L3)
b. Write a automata code for L(M)= a + aa*b + a*b.
c Write a automata code for Let Σ = {0, 1}.

Given NFAs for {}, {ε}, {(ab)n | n ∈ N}, which has regular expression (ab)*.

12. Write a program to convert NFA to DFA (CLO5-L2)

13. Explain in detail about communication using UDP with example. .(CLO5-L1)

Downloaded by Sudharsanan Radhakrishnan ([email protected])


lOMoARcPSD|23351831

Downloaded by Sudharsanan Radhakrishnan ([email protected])

You might also like