Sorry For Inconvenience, Site is Under Maintenance. Please Goto HomePage

Python 3 Application Programming Fresco Play MCQs Answers

Python 3 Application Programming Fresco Play MCQs Answers
Notes Bureau
Python 3 Application Programming Fresco Play MCQs Answers

Disclaimer: The main motive to provide this solution is to help and support those who are unable to do these courses due to facing some issue and having a little bit lack of knowledge. All of the material and information contained on this website is for knowledge and education purposes only.

Try to understand these solutions and solve your Hands-On problems. (Not encourage copy and paste these solutions)
Python 3 Application Programming Fresco Play MCQs Answers
Course Path: Data Science/DATA SCIENCE BASICS/Python 3 Application

All Question of the Quiz Present Below for Ease Use Ctrl + F to find the Question.

Suggestion: If you didn't find the question, Search by options to get a more accurate result.


Quiz on Files

1.What does the match method of re module do?

  1. It matches the pattern at end of the string
  2. It matches the pattern at any position of the string
  3. It matches a pattern at the start of the string
  4. No such method exists

Answer: 3)It matches a pattern at the start of the string

2.What is the output of the expression re.split(r'[aeiou]', 'abcdefghij')?

  1. ['abcd', 'efgh', 'ij']
  2. ['a', 'bcd', 'e', 'fgj', 'i', 'j']
  3. Results in error
  4. ['', 'bcd', 'fgh', 'j']

Answer: 4)['', 'bcd', 'fgh', 'j']

3.Which of the following syntax is used to name a grouped portion of a match?

  1. ?P
  2. ?
  3. ?G

Answer: 2)?P

4.What does seek method of a file object do?

  1. Moves the current file position to a different location at a defined offset.
  2. Tells the current position within the file and indicates that the next read or write occurs from that position in a file.
  3. Returns various values associated with file object as a tuple
  4. Determines if the file position can be moved or not.

Answer: 1)Moves the current file position to a different location at a defined offset.

5.Which of the following expression is used to compile the pattern p?

  1. re.assemble(p)
  2. re.compile(p)
  3. re.regex(p)
  4. re.create(p)

Answer: 2)re.compile(p)

6.Which of the following modules support regular expressions in Python?

  1. re
  2. regex
  3. regexp
  4. reg

Answer: 1)re

7.Which of the following methods of a match object mo is used to view the grouped portions of match in the form of a tuple?

  1. mo.group(0)
  2. mo.group()
  3. mo.groups()
  4. mo.group(1)

Answer: 3)mo.groups()

8.In a match found by a defined pattern, how to group various portions of a match?

  1. Using braces, {}
  2. Using angular brackets, <>
  3. Using square brackets, []
  4. Using paranthesis, ()

Answer: 4)Using paranthesis, ()

9.What does the search method of re module do?

  1. No such method exists
  2. It matches a pattern at the start of the string.
  3. It matches the pattern at end of the string.
  4. It matches the pattern at any position of the string.

Answer: 4)It matches the pattern at any position of the string.



Quiz on Database Connectivity

1.Which of the following method is used to fetch all the rows of a query result?

  1. fetchone
  2. fetch
  3. select
  4. fetchall

Answer: 4)fetchall

2.Which of the following method is used to insert multiple rows at a time in sqlite3 datatbase?

  1. execute
  2. insert
  3. insertmany
  4. executemany

Answer: 4)executemany

3.Which of the following package provides the utilities to work with Oracle database?

  1. oracle
  2. cx_Oracle
  3. cx_Pyoracle
  4. pyoracle

Answer: 2)cx_Oracle

4.pyodbc is an open source Python module that makes accessing ODBC databases simple.

  1. False
  2. True

Answer: 2)True

5.Which of the following package provides the utilities to work with MongoDB database?

  1. mongodb
  2. pymongo
  3. pymongodb
  4. mongopy

Answer: 2)pymongo

6.While using Object relation mappers for database connectivity, a table is treated as ____________.

  1. Function
  2. Method
  3. Object
  4. Class

Answer: 4)Class

7.Django web framework uses SQLAlchemy as Object-relational mapper.

  1. True
  2. False

Answer: 2)False

8.Which of the following package provides the utilities to work with postgreSQL database?

  1. psycopg2
  2. pypostgres2
  3. postgres2
  4. postgresql

Answer: 1)psycopg2

9.Which of the following package provides the utilities to work with MySQLDB database?

  1. MySQLdb
  2. mysqldb
  3. mysqlpkg
  4. mysql

Answer: 1)MySQLdb

10.Which of the following method is used to fetch next one row of a query result?

  1. fetchone
  2. fetch
  3. select
  4. fetchall

Answer: 1)fetchone



Quiz on Higher Order Functions

1.What is the output of the following code?

def outer(x, y):

    def inner1():

        return x+y

    def inner2():

        return x*y

    return (inner1, inner2)

(f1, f2) = outer(10, 25)

print(f1())

print(f2())

  1. 35
    250
  2. 35 250
  3. 250
    35
  4. 250 35

Answer: 1)35
250

2.What is the output of the following code?

def multipliers():

    return [lambda x : i * x for i in range(4)]

print([m(2) for m in multipliers()])

  1. [0,1,2,3]
  2. [0,2,4,6]
  3. [0,0,0,0]
  4. [6,6,6,6]

Answer: 4)[6,6,6,6]

3.What is the output of the following code?

def outer(x, y):

    def inner1():

        return x+y

    def inner2(z):

        return inner1() + z

    return inner2

f = outer(10, 25)

print(f(15))

  1. 50
  2. Error
  3. 60
  4. 45

Answer: 1)50

4.A closure does not hold any data with it.

  1. False
  2. True

Answer: 1)False

5.Which of the following is false about the functions in Python?

  1. A(x: 12, y: 3)
  2. A function can be returned by some other function
  3. A function can be passed as an argument to another function
  4. A function can be treated as a variable

Answer: 1)A(x: 12, y: 3)

6.What is the output of the following code?

def f(x):

    return 3*x

def g(x):

    return 4*x

print(f(g(2)))

  1. 8
  2. 6
  3. 24
  4. Error

Answer: 3)24

7.What is the output of the following code?

v = 'Hello'

def f():

    v = 'World'

    return v

print(f())

print(v)

  1. Hello
    Hello
  2. World
    World
  3. Hello
    World
  4. World
    Hello

Answer: 4)World
Hello

8.A closure is always a function.

  1. False
  2. True

Answer: 2)True


Quiz on Decorators


1.Which of the following is true about decorators?

  1. Decorators always return None
  2. dec keyword is used for decorating a function
  3. Decorators can be chained
  4. A Decorator function is used only to format the output of another function

Answer: 3)Decorators can be chained

2.What is the output of the following code?

def bind(func):

    func.data = 9

    return func

@bind

def add(x, y):

    return x + y

print(add(3, 10))

print(add.data)

Error

  1. 13
  2. 9
  3. 9
  4. 13

Answer: 1)13

3.What is the output of the following code?

from functools import wraps

def decorator_func(func):

    @wraps(func)

    def wrapper(*args, **kwargs):

        return func(*args, **kwargs)

    return wrapper

@decorator_func

def square(x):

    return x**2

print(square.__name__)

  1. Error
  2. wrapper
  3. decorator_func
  4. square

Answer: 4)square

4.What is the output of the following code?

def star(func):

    def inner(*args, **kwargs):

        print("*" * 3)

        func(*args, **kwargs)

        print("*" * 3)

    return inner

def percent(func):

    def inner(*args, **kwargs):

        print("%" * 3)

        func(*args, **kwargs)

        print("%" * 3)

    return inner

@star

@percent

def printer(msg):

    print(msg)

printer("Hello")

  1. ***
    %%%
    Hello
    %%%
    ***
  2. %%%
    ***
    Hello
    ***
    %%%
  3. %%%
    ***
    Hello
    %%%
    ***
  4. ***
    ***
    Hello
    %%%
    %%%

Answer: 1)***
%%%
Hello
%%%
***

5.What is the output of the following code?

def smart_divide(func):

    def wrapper(*args):

        a, b = args

        if b == 0:

            print('oops! cannot divide')

            return

        return func(*args)

    return wrapper

@smart_divide

def divide(a, b):

    return a / b

print(divide.__name__)

print(divide(4, 16))

print(divide(8,0))

  1. smart_divide
    0.25
    oops! cannot divide
  2. wrapper
    0.25
    oops! cannot divide
  3. smart_divide
    0.25
    oops! cannot divide
    None
  4. wrapper
    0.25
    oops! cannot divide
    None

Answer: 4)wrapper
0.25
oops! cannot divide
None

6.Classes can also be decorated, if required, in Python.

  1. False
  2. True

Answer: 2)True


Quiz on Descriptors and Properties


1.What is the output of the following code?

class A:

    def __init__(self, val):

        self.x = val

    @property

    def x(self):

        return self.__x

    @x.setter

    def x(self, val):

        self.__x = val

    @x.deleter

    def x(self):

        del self.__x

a = A(7)

del a.x

print(a.x)

  1. TypeError
  2. 7
  3. AttributeError
  4. ValueError

Answer: 3)AttributeError

2.What is the output of the following code?

class A:

    def __init__(self, value):

        self.x = value

    @property

    def x(self):

        return self.__x

    @x.setter

    def x(self, value):

        if not isinstance(value, (int, float)):

            raise ValueError('Only Int or float is allowed')

        self.__x = value

a = A(7)

a.x = 'George'

print(a.x)

  1. ValueError
  2. AttributeError
  3. 7
  4. George

Answer: 1)ValueError

3.Which of the following method definitions can a descriptor have?

  1. __get__ or __set__
  2. __get__, __set__
  3. any of __get__, set__, __delete__
  4. __get__, __set__, __delete__

Answer: 3)any of __get__, set__, __delete__

4.What is the output of the following code?

class A:

    def __init__(self, x):

        self.__x = x

    @property

    def x(self):

        return self.__x

a = A(7)

a.x = 10

print(a.x)

  1. 10
  2. None
  3. AttributeError
  4. 7

Answer: 3)AttributeError

5.If a property named temp is defined in a class, which of the following decorator statement is required for deleting the temp attribute ?

  1. @temp.delete
  2. @property.deleter.temp
  3. @property.delete.temp
  4. @temp.deleter

Answer: 4)@temp.deleter

6.What is the output of the following code?

class A:

    def __init__(self, x , y):

        self.x = x

        self.y = y

    @property

    def z(self):

        return self.x + self.y

  1. a = A(10, 15)

Answer: )

b = A('Hello', '!!!')

print(a.z)

print(b.z)

  1. 25
  2. 25
    Hello!!!
  3. 25
    25
  4. Error

Answer: 2)25
Hello!!!

7.If a property named temp is defined in a class, which of the following decorator statement is required for setting the temp attribute?

  1. @temp.set
  2. @temp.setter
  3. @property.set.temp
  4. @property.setter.temp

Answer: 2)@temp.setter

8.Which of the following is true about property decorator?

  1. property decorator is used either for getting, setting or deleting an attribute
  2. property decorator is used either for setting or getting an attribute.
  3. property decorator is used only for setting an attribute
  4. property decorator is used only for getting an attribute

Answer: 1)property decorator is used either for getting, setting or deleting an attribute


Python


1.What is the output of the following code?

def s1(x, y):

    return x*y

class A:

    @staticmethod

    def s1(x, y):

        return x + y

    def s2(self, x, y):

        return s1(x, y)

a = A()

print(a.s2(3, 7))

  1. 10
  2. 4
  3. TypeError
  4. 21

Answer: 4)21

2.What is the output of the following code?

class A:

    @staticmethod

    def m1(self):

        print('Static Method')

    @classmethod

    def m1(self):

        print('Class Method')

A.m1()

  1. Class Method
  2. Static Method
  3. TypeError
  4. Static Method
    Class Method

Answer: 1)Class Method

3.What is the output of the following code?

class A:

    @classmethod

    def m1(self):

        print('In Class A, Class Method m1.')

    def m1(self):

        print('In Class A, Method m1.')

a = A()

a.m1()

  1. TypeError
  2. In Class A, Method m1.
  3. In Class A, Class Method m1.
  4. In Class A, Class Method m1.
    In Class A, Method m1.

Answer: 2)In Class A, Method m1.

4.Which of the following decorator function is used to create a class method?

  1. classmethod
  2. classfunc
  3. classdef
  4. class

Answer: 1)classmethod

5.What is the output of the following code?

class A:

    @classmethod

    def getC(self):

        print('In Class A, method getC.')

class B(A):

    pass

b = B()

B.getC()

b.getC()

  1. AttributeError
  2. In Class A, method getC.
    In Class A, method getC.
  3. In Class A, method getC.
  4. TypeError

Answer: 2)In Class A, method getC.
In Class A, method getC.

6.The static Method is bound to Objects and Class.

  1. True
  2. False

Answer: 2)False

7.What is the output of the following code?

class A:

    @staticmethod

    @classmethod

    def m1(self):

        print('Hello')

A.m1(5)

  1. AttributeError
  2. TypeError
  3. ValueError
  4. Hello

Answer: 2)TypeError

8.Which of the following decorator function is used to create a static method?

  1. staticdef
  2. static
  3. staticmethod
  4. staticfunc

Answer: 3)staticmethod


Quiz on Abstract Classes


1.What is the output of the following code?

from abc import ABC, abstractmethod

class A(ABC):

    @classmethod

    @abstractmethod

    def m1(self):

        print('In class A, Method m1.')

class B(A):

    @classmethod

    def m1(self):

        print('In class B, Method m1.')

b = B()

b.m1()

B.m1()

A.m1()

  1. In class B, Method m1.
    In class B, Method m1.
    In class A, Method m1.
  2. In class B, Method m1.
  3. TypeError
  4. In class B, Method m1.
    In class B, Method m1.

Answer: 1)In class B, Method m1.
In class B, Method m1.
In class A, Method m1.

2.Which of the following module helps in creating abstract classes in Python?

  1. ABC
  2. abc
  3. abstractclass
  4. abstract

Answer: 2)abc

3.What is the output of following code?

from abc import ABC, abstractmethod

class A(ABC):

    @abstractmethod

    def m1():

        print('In class A, Method m1.')

    def m2():

        print('In class A, Method m2.')

class B(A):

    def m2():

        print('In class B, Method m2.')

b = B()

b.m2()

  1. In class A, Method m2.
  2. In class A, Method m1.
  3. In class B, Method m2.
  4. TypeError

Answer: 1)In class A, Method m2.

4.What is the output of following code?

from abc import ABC, abstractmethod

class A(ABC):

    @abstractmethod

    def m1():

        print('In class A.')

a = A()

a.m1()

  1. AbstratError
  2. TypeError
  3. ClassError
  4. In class A.

Answer: 2)TypeError

5.What is the output of the following code?

from abc import ABC, abstractmethod

class A(ABC):

    @abstractmethod

    def m1(self):

        print('In class A, Method m1.')

class B(A):

    def m1(self):

        print('In class B, Method m1.')

class C(B):

    def m2(self):

        print('In class C, Method m2.')

c = C()

c.m1()

c.m2()

  1. In class B, Method m1.
    In class C, Method m2.
  2. In class A, Method m1.
    In class C, Method m2.
  3. In class A, Method m1.
    In class B, Method m1.
  4. TypeError

Answer: 1)In class B, Method m1.
In class C, Method m2.

6.What is the output of the following code?

from abc import ABC, abstractmethod

class A(ABC):

    @abstractmethod

    def m1(self):

        print('In class A, Method m1.')

class B(A):

    @staticmethod

    def m1(self):

        print('In class B, Method m1.')

b = B()

B.m1(b)

  1. In class A, Method m1.
  2. AttributeError
  3. TypeError
  4. In class B, Method m1.

Answer: 4)In class B, Method m1.

7.What is the output of the following code?

from abc import ABC, abstractmethod

class A(ABC):

    @abstractmethod

    @classmethod

    def m1(self):

        print('In class A, Method m1.')

class B(A):

    @classmethod

    def m1(self):

        print('In class B, Method m1.')

b = B()

b.m1()

B.m1()

A.m1()

  1. In class B, Method m1.
    In class B, Method m1.
    In class A, Method m1.
  2. AttributeError
  3. TypeError
  4. In class B, Method m1.
    In class B, Method m1.

Answer: 2)AttributeError

8.Which of the following decorator function is used to create an abstract method?

  1. abstract
  2. abstractmethod
  3. abstractdef
  4. abstractfunc

Answer: 2)abstractmethod


Quiz on Context Managers


1.What is the output of the following code?

from contextlib import contextmanager

@contextmanager

def tag(name):

    print("<%s>" % name)

    yield

    print("</%s>" % name)

with tag('h1') :

    print('Hello')

  1. <%h1>
    Hello
    </%h1>
  2. Hello
  3. <h1>
    </h1>
    Hello
  4. <h1>
    Hello
    </h1>

Answer: 4)<h1>
Hello
</h1>

2.What does the context manager do when you are opening a file using with?

  1. It writes into the opened file
  2. It closes the opened file automatically
  3. It does nothing
  4. It opens the file automatically

Answer: 2)It closes the opened file automatically

3.Popen of subprocess module is a context manager.

  1. True
  2. False

Answer: 1)True

4.Which of the following module helps in creating a context manager using decorator contextmanager?

  1. contextlib
  2. contextmanager
  3. manage
  4. managelib

Answer: 1)contextlib


Quiz on Coroutines


1.Select the correct statement that differentiates a Generator from a Coroutine.

  1. Generators and Coroutines output values
  2. Only Generators output values
  3. Generators and Coroutines take input values
  4. Only Coroutines take input values

Answer: 4)Only Coroutines take input values

2.What is the output of the following code?

def stringParser():

    while True:

        name = yield

        (fname, lname) = name.split()

        f.send(fname)

        f.send(lname)

def stringLength():

    while True:

        string = yield

        print("Length of '{}' : {}".format(string, len(string)))

f = stringLength(); next(f)

s = stringParser()

next(s)

s.send('Jack Black')

  1. Length of 'Jack' : 4
  2. Length of 'Jack' : 4
    Length of 'Black' : 5
  3. Results in Error
  4. Length of 'Jack Black' : 10

Answer: 2)Length of 'Jack' : 4
Length of 'Black' : 5

3.What is the output of the following code?

def stringDisplay():

    while True:

        s = yield

        print(s*3)

c = stringDisplay()

next(c)

c.send('Hi!!')

  1. TypeError
  2. Hi!!Hi!!Hi!!
  3. Hi!!
    Hi!!
    Hi!!
  4. Hi!!

Answer: 2)Hi!!Hi!!Hi!!

4.What is the output of the following code?

def nameFeeder():

    while True:

        fname = yield

        print('First Name:', fname)

        lname = yield

        print('Last Name:', lname)

n = nameFeeder()

next(n)

n.send('George')

n.send('Williams')

n.send('John')

  1. First Name: George
    Last Name: Williams
  2. First Name: George
    Last Name: Williams
    First Name: John
  3. First Name: George
  4. Results in Error

Answer: 2)First Name: George
Last Name: Williams
First Name: John

5.Which of the following methods is used to pass input value to a coroutine?

  1. input
  2. pass
  3. bind
  4. send

Answer: 4)send

6.A Coroutine is a generator object.

  1. False
  2. True

Answer: 2)True

7.What is the output of the following code?

def stringDisplay():

    while True:

        s = yield

        print(s*3)

c = stringDisplay()

c.send('Hi!!')

  1. Hi!!
    Hi!!
    Hi!!
  2. TypeError
  3. Hi!!
  4. Hi!!Hi!!Hi!!

Answer: 2)TypeError


Python 3 Application Programming - Final Assessment


1.What does tell method of a file object do?

  1. Tells the current position within the file and indicate that the next read or write occurs from that position in a file.
  2. Determines if the file position can be moved or not.
  3. Changes the file position only if allowed to do so else returns an error.
  4. Moves the current file position to a different location at a defined offset.

Answer: 1)Tells the current position within the file and indicate that the next read or write occurs from that position in a file.

2.What is the output of the expression re.sub(r'[aeiou]', 'X', 'abcdefghij')?

  1. Xbcdefghij
  2. Results in Error
  3. abcdefghij
  4. XbcdXfghXj

Answer: 4)XbcdXfghXj

3.Which of the following methods have to be defined in a class to make it act like a context manager?

  1. enter, quit
  2. enter, exit
  3. __enter__, __exit__
  4. __enter__, __quit__

Answer: 3)__enter__, __exit__

4.Which of the following statement is used to open the file C:\Sample.txt in append mode?

  1. open('C:\Sample.txt', 'w+')
  2. open('C:/Sample.txt', 'a')
  3. open('C:\Sample.txt', 'w')
  4. open('C:\Sample.txt', 'r+')

Answer: 2)open('C:/Sample.txt', 'a')

5.ZipFile utility of zipfile module is a context manager.

  1. True
  2. False

Answer: 1)True

6.Which of the following keywords is used to enable a context manager in Python?

  1. context
  2. enable
  3. contextmanager
  4. with

Answer: 4)with

7.Which of the following methods of a match object, mo, is used to view the named group portions of match in the form of a dictionary

  1. mo.groupdict()
  2. mo.dict()
  3. mo.gdict()
  4. mo.group()

Answer: 1)mo.groupdict()


2 comments

  1. Can you please help Selenium-Webdriver Hands-on??
    1. Thanks for your comment. Please check Selenium Webdriver Answers uploaded.
Any comments and suggestion will be appreciated.
Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.

Join Telegram Channel

Join Notes Bureau Lets Teach and Learn

Join Telegram Channel
CLOSE ADS
CLOSE ADS