APP Holy Book - Advanced Programming Practice
APP Holy Book - Advanced Programming Practice
A.
SECTION-A
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
A. Algol 68
B. Ada 95
C. pascal
D. Ada 83.
ANSWER: B
A. statements
B. objects
C. classes
D. operations
ANSWER: A
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
for x in fruits:
if x == "banana":
break
print(x)
A. banana
B. apple
D. rror
ANSWER: B
A. modules
B. sub programs
C. paradigm
D. operations
ANSWER: B
A. Procedural Programming
C. Progressive Programming
ANSWER: B
1 11 In Procedural Programming, programs are divided into different procedures also known as
ANSWER: A
A. modules
B. sub programs
C. paradigm
D. operations
ANSWER: B
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()?
Square object
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
A. Procedure
B. Object Oriented
C. Declarative D. Functional
ANSWER: C
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?
A. names.add(8Kevin9)
B. names.append(8Kevin9)
C. names(colors,
D. names.arrayadd(
ANSWER: B
A. 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
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
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
delattr(b,9ball9) A.
del b.ball
B. ball.b del
C. attrdel(b.ball)
D. b.ball(delattr)
ANSWER: A
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
D. Propositions, Unification
ANSWER: A
ANSWER: B
A. c, ∪, +
B. ∪, +,¬
C. &&, ∥
D. £,>,<
ANSWER: D
A. parent(x, y) ¢ mother(x, y)
B. parent(x, y) ¢ father(x, y)
ANSWER: C
ANSWER: C
return sum+b
sum++
B. a=10
b=10
return a+b+2
a=a+10
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
A. Exception thrown
B. 35
C. 25
D. add(10)
ANSWER: B
B. Recursive calls are expensive as they take up a lot of memory and time
D. Sequence generation is easier with nested functions in relation with recursive functions
ANSWER: B
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
ANSWER: C
2 36 What is the output of the following segment according to the given Statements: fromsympy
import tan
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)
ANSWER: B
∫ 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?
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 *
A. Matrix([[2],[1]])
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?
x = Symbol('x') y = Symbol('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))
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
ANSWER: B
3 45 Dependent type paradigm used to encode logic's quantifiers like _____and _______
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
A. Processing
B. Parallel processing
C. Serial Processing
D. Multi-Tasking
ANSWER: B
A. Process
D. A computer program
ANSWER: C
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
A. getName()
B. setName()
C. putName()
D. fetchName()
ANSWER: A
ANSWER: D
ANSWER: B
A. threadLock.release()
B. release()
C. thread_id.release()
D. th_release()
ANSWER: A
A. statements
B. objects
C. classes
D. operations
ANSWER: A
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
x in fruits:
if x == "banana":
break
print(x)
A. banana
B. apple
D. rror
ANSWER: B
A. modules
B. sub programs
C. paradigm
D. operations
ANSWER: B
A. Procedural Programming
C. Progressive Programming
ANSWER: B
4 61 In Procedural Programming, programs are divided into different procedures also known as
ANSWER: A
4 62 Which of the following is the advantage of declarative languages over imperative languages?
C. Is more efficient
ANSWER: B
B. style of building programs that expresses logic of computation without talking about its control
flow
ANSWER: D
B. code executes too slowly for optimal results on complex data science applications
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
disp("Hello World!")
B. Hello World
C. Hello World!
D. ERROR
ANSWER: A
hof(3, lambda x: x * x)
A. 3
B. 9
C. 12
D. ERROIR
ANSWER: C
A. Listoflist={listA},{ListB}
B. Listoflist=[listA,ListB]
C. Listoflist=[list+ListB]
D. Listoflist=[listA]+[ListB]
ANSWER: B
A. To access values in tuple, use the square brackets along with the index
ANSWER: D
ANSWER: C
A. mydict = thisdict.copyTo()
B. mydict = thisdict.copy()
D. dict2=dict1
ANSWER: B
4 72 Which among the following is not a part of Abstract Data Types interface?
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
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
ANSWER: A
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?
B. Datagram Socket()
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()
C. Scale()
D. Spinbox()
ANSWER: D
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
5 85 How many reference variables and objects are there for the given Python code?
class hello:
print("Inside class")
obj=hello() A. 3 and
B. 4 and 1
C. 1 and 4
D. 1 and 3
ANSWER: C
5 86 class stud:
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
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
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
SECTION - B
i=5
def f(arg=i):
print(arg) i =
6 f()
A. 5
B. 6
C. ERROR D. 5.6
ANSWER: A
if condition:
B. if
condition:
statement1
statement2
C. if
(condition):
statement elif
(condition):
statement
else:
statement
D. if
(condition):
Statement; elif
(condition):
statement;
ANSWER: D
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
ADDRESS CHAR(50),
SALARY INT;)
Dem
ADDRESS CHAR(50),
SALARY INT;''');
ADDRESS CHAR(50),
SALARY INT;''');
ADDRESS CHAR(50),
SALARY INT;''');
ADDRESS CHAR(50),
SALARY INT;''');
ANSWER:
ANSWER: A
A. Procedure
B. Structure
C. Declarative D. Functional
ANSWER: B
num1 = 5 if
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
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
values = [1, 2, 1, 3]
checkit(num): if num 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
3, 4]
myfunc(*nums)
A. 3
B. 1
C. 4
D. 5
ANSWER: A
ANSWER: C
A. socket.AF_INET
B. socket.DGRAM
C. protocol D. IP
ANSWER: D
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()
C. sock_object.sent()
D. sock_object.sendto()
ANSWER: A
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)
m.add_cascade(label="File", menu=filemenu)
B. m= Menu(root)
filemenu = Menu(m)
m.add_cascade(label="File")
C. m= Menu(root)
m.add_cascade(label="File", menu=filemenu)
D. m= Menubar(root)
filemenu = Menubar(m)
m.add_cascade(label="File")
ANSWER: C
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=?
ANSWER: C
2 19 Consider the following output. What is the correct syntax for creating field <Submit= in the
above window?
"Submit").grid(row = 0, column = 0)
"Submit").grid(row = 0, column = 0)
"Submit").grid(row = 2, column = 0)
"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=)
C. title(<Programming Language=)
D. window(<Programming Language=)
ANSWER: B
class first: a = 10 b
= 20
def add(self):
print(sum) ob = first()
print(first.a) print(ob.b)
ob.add()
A. 0 20 30
B. 10 20 30
C. 10 20 0
D. error
ANSWER: B
20
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
ANSWER: C
ANSWER: D
B. Symbolic programming
C. Automata programming
ANSWER: D
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.
ANSWER: B
ANSWER: D
3 27 Which of the following is correct for predicate <All men drink 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)
ANSWER: B
A. spawn
B. fork
C. forkserver
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
ANSWER: C
3 33 Consider the below given code and guess what value will x return in this code
def f(x):
ANSWER: D
B. include pool
C. import pool_class
D. include poolclass
ANSWER: A
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
B. def cube(x):
C. for x in numbers :
ANSWER: D
4 37 Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after list1.pop(1)?
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
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
print(matched.groupdict())
A. {8animal9:9deers9,9verb9:9are9,9adjective9:9fast9}
B. {8deers9,9are9,9fast9}
ANSWER: A
sq(a):
cu(a):
print value A.
fcs=[sq,cu,1]
B. fcs[cu,sq]
C. fcs=[sq,cu]
D. fcs[1,sq,cu]
ANSWER: C
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)
ANSWER: B
ANSWER: D
4 43 Demonstrate the equivalent lambda function for the function cube to compute cube of a
number
D. g = lambda(x*x*x ) (5)
ANSWER: A
def sum_args(*numbers):
return sum(numbers)
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
ANSWER: C
1. i=1
while True:
print(i)
i=i+1
break
A. 1 2 3
B. 1
C. 2
D. 3
ANSWER: A
fruits:
if x == "banana":
continue
print(x)
A. banana
B. apple cherry
D. apple banana
ANSWER: B
print(len(list(map(len, x))))
A. 2
B. 1
C. 0
D. ERROR
ANSWER: D
importsympy as sym
= x + y + z exps =
sym.expand(given_exp**2)
is: ",format(diffre))
ANSWER: A
= 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 *
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
class first: a = 10 b
= 20
def add(self):
print(sum) ob = first()
print(first.a) print(ob.b)
ob.add()
A. 0 20 30
B. 10 20 30
C. 10 20 0 D. error
ANSWER: B
20
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
ANSWER: C
ANSWER: D
B. Symbolic programming
C. Automata programming
ANSWER: D
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
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):
__init__(self):
class C(B):
code -----
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
A. Symbolic programming
B. Automata programming
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
WButton =
SButton.grid( row=0,column=1
SButton.grid( row=1,column=1
NButton.place(E)
EButton.place(N)
SButton.place(W)
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
B. 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
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
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):
= id
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.
B. def cube(x):
for x in mynumbers:
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 ____________
ANSWER : A
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
(Fahrenheit)
even
ANSWER : A
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:
print("Finally finished!")
A. 1
Finally finished
B. 0 1
C. 0
Finally finished
D. ERROR
ANSWER : C
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)
YKNJS(L)
C. IndexError
ANSWER : B
for i in range(len(L)):
if L[i]:
else:
Break
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:
row in cursor:
ANSWER : A
defoddTimes(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
print n
1)Throw an error
A. 1 & 2 is wrong
B. 3 alone is wrong
C. 4 alone is wrong
ANSWER : D
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)
B. pyDatalog.create_terms('pass9: X>50)
C. pyDatalog.create_terms('pass9) pass(X)<=
D. pyDatalog.create_terms('pass9: X<=50)
ANSWER : C
5 28 Given the following facts and rules, display the results using Queries in PyDatalog
Facts:
father ('Bill','Dany')
('Cathy','Furon') father
('Alan','Bob') father
('Alan','Cathy')
Rules:
A. Father only
C. father, cousin, brother, grandson, descendent, Alan, bill, Cathy, Dany, Ellen, Furon
ANSWER : D
integrate(exp(x)*sin(x)) print("The
root)
ANSWER : A
sin(x)*sin(y) cot(x + y)
=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
Which of the following programming paradigms allow us to write programs and know they
are correct before running them?
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)
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=?
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.∀xP(x)
b.ΣP(x)
c.∅xP(x)
d.∃xP(x)
a. ∅xclock(x)->quartz(x)
b. ∃xclock(x)->quartz(x)
c. ∀xclock(x)->quartz(x)
d. none of the above
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
14. Dependent type paradigm used to encode logic's quantifiers like _____and _______
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:
17. Predict the output of the below mentioned python code with dependent type syntax:
from typing import List
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
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)
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)
2. Which method used by the server to initiate the connection with the client?
i. Listen()
ii. Close()
iii. Bind()
iv. Accept()
i. TCP
ii. UDP
iii. HTTP
iv. FTP
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()
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()
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()
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
4) It sets the lock state to locked. If called on a locked object, it blocks until the resource is free.
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
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
10) A race condition occurs when multiple processes or threads read and write
11) For a single processor system, implementation of semaphores is possible to inhibited through
a) By Thread.create() b) By Thread.start()
c) None d) By Thread.run()
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?
18. Which synchronization method is used to guard the resources with limited capacity, e.g. a database
server?
a)numpy b)scikit
c)sys d) functools
a)evalf b)fval
c) float d) valf
a)5 b) oo
c) 1 d) 0
>>> x = Symbol('x')
>>> y = Symbol('y')
>>> A**2
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)
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
a) solve(equation,range) b)equation(solve,range)
14) Allows , the same elements can appear multiple times at different positions
a) set b)sequence
c) dictionary d) none
2 2]
x = symbols('x')
expr = sin(x)/x;
print("Expression : {}".format(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()
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
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}
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
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
Ans: A
22. Which of the following is correct among the following expressions? (CLO5-L2)
i.
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
Ans: A
Ans: C
Ans: B
Ans: B
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
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)
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
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)
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
Ans:c
PART: B (4MARKS)
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)
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)
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)
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)
Given NFAs for {}, {ε}, {(ab)n | n N}, which has regular expression (ab)*.
13. Explain in detail about communication using UDP with example. .(CLO5-L1)
UNIT 4
c)Scaling d)Vectorization
Ans:a
a.Patterns, examples
b.Algorithms , flowcharts
c.Models , methods
d.Classes ,objects
Ans:a
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
a) Process based
b) Thread based
Ans:c
5.What will happen if two thread of the same priority are called to be processed
simultaneously? (CLO-4,L2)
Ans:d
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
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
a) multiprogramming
b) multitasking
c) multiprocessing
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
a. gevent.Greenlet
b. gevent.spawn()
c.gevent.spawn_later()
d.gevent.spawn_raw()
Ans:a
(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)
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 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)
Ans: b
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)
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)
Ans: d
17. What is the first order predicate calculus statement equivalent to the following? (CLO-4,L3)
(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)]]
(D) ∀ (x) [teacher (x) ^ ∃ (y) [student (y) → likes (y, x)]]
Ans: b
18.
(B) I and IV
(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
a) overload
b) typing
c) literal
Ans: c
21. __________ is required to define multiple function declarations with different input types
and results. .(CLO-4,L1)
a) overload
b) typing
c) literal
Ans: a
2. Implement the concept <Pool class= by importing a package pool. (CLO-4, L3)
4. Explain the differences between multithreading and multiprocessing with example? (CLO-4,
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)
Automata is a Python 3 library which implements the structures and algorithms for finite automata, pushdown
automata, and Turing machines.
Installing
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 .
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)
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)
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 .
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 .
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
# DFA which matches all binary strings ending in an odd number of '1's
dfa = DFA(
input_symbols={'0', '1'},
transitions={
},
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_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')
# 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.copy(self)
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.
minimal_dfa = dfa.minify()
DFA.from_nfa(cls, nfa)
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.
# NFA which matches strings beginning with 'a', ending with 'a', and containing
# no consecutive 'b's
nfa = NFA(
input_symbols={'a', 'b'},
transitions={
# Use '' as the key name for empty string (lambda/epsilon) transitions
},
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_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'}
# {'q1', 'q2'}
NFA.accepts_input(self, input_str)
if nfa.accepts_input(my_input_str):
print('accepted')
else:
print('rejected')
NFA.validate(self)
NFA.copy(self)
NFA.from_dfa(cls, dfa)
UNIT-1
MULTIPLE CHOICE QUESTIONS
A (*arg) B.(arg)
9. print() is _________[CLO-1,L1]
Ans:A
(Ans:A)
(Ans: B)
(Ans: B)
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()
ob.func1()
ob.func2()
ob.func3()
(Ans:A)
Ans A
A.6,36 B.36,36
C 11,10 D.15,10
Ans:A
(Ans: C)
21.Which one of the following is the correct way of calling a function? [CLO-1,L2]
Ans:D
def outerFun(c,d):
def innerFun(e, f):
return e + f
return innerFun(c, d)
return c
result = outerFun(10, 5)
print(result)
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)
---------
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):
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)
Ans D
What is the correct syntax to execute the printname method of the object x? [CLO-1,L3]
class Person:
self.firstname = fname
def printname(self):
print(self.firstname)
class Student(Person):
pass
x = Student("Mike")
------------------
A.x.printname() B.x.PrinName();
C.x.printfname() C.x(printname());
Ans: A
-------------- mymodule
A.import B.include
C.inheret D.insert
Ans A
-------=-----
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))
-----------
C.string D.strs
Ans B
31.The following code example would print the data type of x, what data type would that be?
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
A.1991 B.1998
C.1992 D.1990
Ans A
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")
Ans A
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)
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)
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)
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)
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)
UNIT-2
(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)
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
(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)
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
(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
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)
(Ans:c)
a.line()
b.canvas.create_line()
c.create_line(canvas)
Answer: b
a.foreground
b.background
c.forgap
Answer: a
c.According to left,right,up,down
Answer: c
57. How does the grid() function put the widget on the screen ?
c.According to left,right,up,down
Answer: b
58. How does the place() function put the widget on the screen ?
c.According to left,right,up,down
Answer: a
a.import tkinter
b.import tkinter as t
Answer: d
b.tkinter install
Answer: c
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
answer: b
PART B: 4 marks:
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
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
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]
UNIT III
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)
Ans:b
Ans:a
Ans:a
Ans:b
Ans:d
Ans:c
Ans:b
Ans:a
Ans:c
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
Ans:b
Ans:a
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
a = 8.6
b=2
print a//b
a)4.3
b) 4.0
c) 4
d) compilation error
Ans:b
Ans:a
(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
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
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
b) outputs
c) tasks
d) None of the mentioned
Ans:a
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)
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
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
Ans:c
Ans:Lisp
45. Haskell lends itself well to ____________due to its explicit handling of effects. (CLO-3,L3)
a.functional programming
b. concurrent programming
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
12. Write a program to check prime numbers using python logic programming(CLO4-L3)
1. Write a logic programming to solve the following Zebra puzzle using python. (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)
UNIT 4
c)Scaling d)Vectorization
Ans:a
a.Patterns, examples
b.Algorithms , flowcharts
c.Models , methods
d.Classes ,objects
Ans:a
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
a) Process based
b) Thread based
Ans:c
5.What will happen if two thread of the same priority are called to be processed
simultaneously? (CLO-4,L2)
Ans:d
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
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
a) multiprogramming
b) multitasking
c) multiprocessing
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
a. gevent.Greenlet
b. gevent.spawn()
c.gevent.spawn_later()
d.gevent.spawn_raw()
Ans:a
(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)
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 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)
Ans: b
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)
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)
Ans: d
17. What is the first order predicate calculus statement equivalent to the following? (CLO-4,L3)
(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)]]
(D) ∀ (x) [teacher (x) ^ ∃ (y) [student (y) → likes (y, x)]]
Ans: b
18.
(B) I and IV
(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
a) overload
b) typing
c) literal
Ans: c
21. __________ is required to define multiple function declarations with different input types
and results. .(CLO-4,L1)
a) overload
b) typing
c) literal
Ans: a
2. Implement the concept <Pool class= by importing a package pool. (CLO-4, L3)
4. Explain the differences between multithreading and multiprocessing with example? (CLO-4,
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)
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
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}
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
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
Ans: A
22. Which of the following is correct among the following expressions? (CLO5-L2)
i.
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
Ans: C
25. Let for ∑= {0,1} R= (∑∑∑) *, the language of R would be-------- (CLO5-L2)
Ans: B
Ans: B
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
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)
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
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)
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
Ans:c
PART: B (4MARKS)
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)
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)
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)
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)
Given NFAs for {}, {ε}, {(ab)n | n ∈ N}, which has regular expression (ab)*.
13. Explain in detail about communication using UDP with example. .(CLO5-L1)