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

Python Qualis Fresco Play MCQs Answers

Python Qualis Fresco Play MCQs Answers
Notes Bureau

Python Qualis 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 Qualis Fresco Play MCQs Answers

Course Path: Data Science/DATA SCIENCE BASICS/Python Qualis

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 Software Testing


1.The discipline of writing tests first and then writing development code is known as ____________.

  1. Test Development
  2. Test Focussed Development
  3. Test Driven Development
  4. Test Preferred Development

Answer: 3)Test Driven Development

2.Which type of testing is performed to check if a program is behaving as expected?

  1. unit testing
  2. regression testing
  3. system testing
  4. acceptance testing

Answer: 4)acceptance testing

3.Which of the following are the unit testing packages availabale in Python?

  1. pytest
  2. All of those Mentioned
  3. doctest
  4. nose
  5. unittest

Answer: 2)All of those Mentioned

4.The testing method, which is used to test individual components of a program is known as ________.

  1. unit testing
  2. system testing
  3. regression testing
  4. acceptance testing

Answer: 1)unit testing

5.Which type of testing is done when one of your existing functions stop working?

  1. unit testing
  2. regression testing
  3. acceptance testing
  4. system testing

Answer: 2)regression testing

6.Unit Testing is the highest level of testing. State true or false.

  1. True
  2. False

Answer: 2)False

7.The real objective of Software testing is to ensure 100% defect free product. State true or false.

  1. True
  2. False

Answer: 2)False

8.Which of the following is the next level of testing to unit testing?

  1. Acceptance testing
  2. Integration testing
  3. system testing
  4. Regression testing

Answer: 2)Integration testing

9.The process of evaluating a software with an intent to determine if it has met the specified requirements is known as __________.

  1. Software Testing
  2. Software Diagnosis
  3. Software Evaluation
  4. Software Debugging

Answer: 1)Software Testing

10.Why Software Testing is necessary?

  1. It makes software reliable and user friendly
  2. It reduces cost by detecting bugs in early stage of development
  3. All of those mentioned
  4. It ensure quality of product

Answer: 3)All of those mentioned

Quiz on doctest


1.Which of the following is true about a docstring?

  1. docstring is a single lie string.
  2. docstring is a document
  3. docstring is optional in a function, class or a module
  4. doctsring is the second statement that appears in a function, class or a module.

Answer: 3)docstring is optional in a function, class or a module

2.Which of the following is a valid doctest?

  1. def add(x, y):

    """Returns sum of two numbers.

    """

    >>> add(5, 6)

    13

    return x + y

  2. def add(x, y):

    return x + y

  3. def add(x, y):

    """Returns sum of two numbers.

    >>> add(5, 6)

    13

    """

    return x + y

  4. def add(x, y):

    """Returns sum of two numbers.

    add(5, 6)

    13

    """

    return x + y

Answer: 3)def add(x, y):
"""Returns sum of two numbers.
>>> add(5, 6)
13
"""
return x + y

3.A sample module named sample_module.py contained the following contents.

def mul(x, y):

    """Multiplies two given numbers and returns the product.

    >>> mul(6, 7)

    42

    >>> mul(-8, 7)

    -56

    """

    return x * y

What is the expected output when you run the doctests using below command?

python -m doctest sample_module.py

  1. No output
  2. Output stating 2 tests passed
  3. Output stating 1 test passed
  4. Output stating 1 failure

Answer: 1)No output

4.Which of the following special attribute can be used to access a doc string in a program?

  1. __docstr__
  2. __str__
  3. __doc__
  4. __document__

Answer: 3)__doc__

5.Which of the following doctest directive is used to ignore part of the result?

  1. # doctest: +IGNORE
  2. # doctest: +COMMENT
  3. # doctest: +ELLIPSIS
  4. # doctest: +ERASE

Answer: 3)# doctest: +ELLIPSIS

6.A sample function sample_fuc is defined as shown below.

def sample_func(x, y):

    """Multiplies two given numbers and returns the product.

    """

    print(x)

    print()

    print(y)

    print()

    print(x*y)

Which of the following doctest correctly tests it's functionality?

  1. >>> sample_func(6, 7)

    6

    BLANKLINE

    7

    BLANKLINE

    42

  2. >>> sample_func(6, 7)

    6

    <BLANKLINE>

    7

    <BLANKLINE>

    42

  3. >>> sample_func(6, 7)

    6

    <blankline>

    7

    <blankline>

    42

  4. >>> sample_func(6, 7)

    6

    7

    42

Answer: 2)>>> sample_func(6, 7)
6
<BLANKLINE>
7
<BLANKLINE>
42

7.Which of the following is a docstring?

  1. A Function
  2. A Class
  3. A Multiline string
  4. A Module

Answer: 3)A Multiline string

8.Which of the following doctest directive is used to deal with unexpected whitespace that appears in the output?

  1. # doctest: +WHITE_SPACE
  2. # doctest: +NORMALIZE_WHITE_SPACE
  3. # doctest: +NORMALIZE_WHITESPACE
  4. # doctest: +WHITESPACE

Answer: 3)# doctest: +NORMALIZE_WHITESPACE

9.A sample module named sample_module.py contained the following contents.

def mul(x, y):

    """Multiplies two given numbers and returns the product.

    >>> mul(6, 7)

    42

    >>> mul(-8, 7)

    >>> -56

    """

    return x * y

What is the expected output when you run the doctests using below command?

python -m doctest sample_module.py

  1. Output stating 2 failures
  2. Output stating 2 tests passed
  3. Output stating 3 tests passed
  4. Output stating 3 failures

Answer: 1)Output stating 2 failures

10.Which of the following doctest directive is used for not considering or executing a specific doctest?

  1. # doctest: +IGNORE
  2. # doctest: +ERASE
  3. # doctest: +SKIP
  4. # doctest: +NEGLECT

Answer: 3)# doctest: +SKIP

11.A doctest mixes documentation and testing. State true or false.

  1. True
  2. False

Answer: 1)True


Quiz on unittest


1.unittest is a xUnit-style based unit testing framework in Python. State true or false.

  1. True
  2. False

Answer: 1)True

2.Which of the following decorator is used to skip a test if a given condition is false, with unittest?

  1. unittest.skipUnless
  2. unittest.skipIf
  3. unittest.skipUntil
  4. unittest.skip

Answer: 1)unittest.skipUnless

3.How many tests are run, when below code is tested using unittest

import unittest

class SampleTestClass(unittest.TestCase):

    def sample_test1(self):

        self.assertEqual('HELLO', 'hello'.upper())

    def test_sample2(self):

        self.assertEqual(3*3, 9)

  1. 1
  2. 3
  3. 0
  4. 2

Answer: 1)1

4.Which of the following is not a component of Xunit-Style Architecture?

  1. Test runner
  2. Test Loader
  3. Assertions
  4. Test fixtures

Answer: 2)Test Loader

5.Which of the following command is execute to run all the test cases present in a project folder using unittest?

  1. python -m unittest
  2. python -m unittest test
  3. python -m unittest start
  4. python -m unittest discover

Answer: 4)python -m unittest discover

6.Which of the following method is used to check if a regular expression matches a string or not, with unittest?

  1. assertRegexpMatches
  2. assertSearch
  3. assertMatch
  4. assertRegexs

Answer: 1)assertRegexpMatches

7.How many tests of sample_module.py shown below, are successfully passed, when run with unittest?

import unittest

class SampleTestClass(unittest.TestCase):

    def test_sample1(self):

        self.assertRaises(TypeError, pow, 2, '4')

    def test_sample2(self):

        self.assertRaises(Exception, max, [7, 8, '4'])

    def test_sample3(self):

        self.assertRaises(TypeError, int, 'hello')

  1. 0
  2. 3
  3. 1
  4. 2

Answer: 1)0

8.Which of the following decorator need to be used while working with setUpClass and tearDownClass fixtures?

  1. @classfixture
  2. @testclass
  3. @classtest
  4. @classmethod

Answer: 4)@classmethod

9.Which of the following commands run only one test case , present in sample_module.py using unittest?

  1. python -m unittest sample_module.TestCase1
  2. python -m unittest sample_module.TestCase1.test_method1
  3. python -m unittest sample_module
  4. python -m unittest

Answer: 2)python -m unittest sample_module.TestCase1.test_method1

10.What is the purpose of using self.id in tests, while working with unittest?

  1. self.id returns the name of method
  2. self.id returns reference value
  3. self.id returns the name of module
  4. self.id returns the name of class

Answer: 1)self.id returns the name of method

11.Test methods are executed alphabetically. State true or false.

  1. False
  2. True

Answer: 2)True

12.Which of the following method is used to catch exceptions in a test, with unittest?

  1. assertException
  2. assertRaises
  3. assertCatch
  4. assert

Answer: 2)assertRaises

13.Which is the expected output of below code, when run using command python -m unittest sample_module.py

import unittest

class SampleTestClass(unittest.TestCase):

    def setUpClass(cls):

        print('Entering Test Class')

    def tearDownClass(cls):

        print('Exiting Test Class')

    def test_sample1(self):

        self.assertEqual(3*3, 9)

  1. Entering Test Class
    .
    Exiting Test Class
  2. Entering Test Class
    .Exiting Test Class
  3. The test run fails.
  4. Entering Test Class
    Exiting Test Class
    .

Answer: 3)The test run fails.

14.Which of the following method is used to check equality of two lists in a test, with unitest?

  1. assertList
  2. assertEqual
  3. assertListEqual
  4. assert

Answer: 3)assertListEqual

15.Which of the following statement ensures that all tests present in sample_test_module.py are run while using the command python sample_test_module.py

  1. unittest.main
  2. unittest.discover
  3. unittest.test
  4. unittest.run

Answer: 1)unittest.main

16.How many tests of sample_module.py shown below, are successfully passed, when run with unittest?

   import unittest

   class SampleTestClass(unittest.TestCase):

    def test_sample1(self):

        self.assertRaises(TypeError, pow, 2, '4')

    def test_sample2(self):

        self.assertRaises(Exception, max, [7, 8, '4'])

    def test_sample3(self):

        self.assertRaises(ValueError, int, 'hello')

  1. 2
  2. 3
  3. 0
  4. 1

Answer: 3)0

17.A single test module contains only one Test Class. State true or false.

  1. False
  2. True

Answer: 1)False

18.What is the parent class from which a Test class has to be derived for running it with unittest?

  1. unittest.unittest
  2. unittest.ParentCase
  3. unittest.Parent
  4. unittest.TestCase

Answer: 4)unittest.TestCase

19.Which of the following command is executed to run all the test cases present in a project folder using unittest?

  1. python -m unittest
  2. python -m unittest start
  3. python -m unittest test
  4. python -m unittest discover

Answer: 4)python -m unittest discover


Quiz on nose


1.Which of the following option is used to generate test report in xml using nose?

  1. --xml
  2. --with-unit
  3. --with-xunit
  4. --with-xml

Answer: 3)--with-xunit

2.Which of the following decorator is used to assign user defined setup and tear down functions to a test function, while using nose?

  1. @setup
  2. @use_setup
  3. @use
  4. @with_setup

Answer: 4)@with_setup

3.nose can recognise tests which are not part of a Test class, derived from a Parent class. State True or False

  1. False
  2. True

Answer: 2)True

4.nose supports use of fixtures at package level. State true or false.

  1. True
  2. False

Answer: 1)True

5.Which of the following command is used to discover all tests in a project and execute them using nose?

  1. python nosetests
  2. nosetests
  3. python nose
  4. nose

Answer: 2)nosetests

6.Which of the following decorator is used to report a test as a failure one, if execution of it takes more than the specified number of seconds?

  1. @timeit
  2. @time
  3. @timecheck
  4. @timed

Answer: 4)@timed

7.Test discovery is simpler in unittest than in nose. State true or false.

  1. True
  2. False

Answer: 2)False

8.ok_ utility from nose.tools is equivalent to ____________.

  1. assert_equal
  2. assert_equals
  3. assert_same
  4. assert

Answer: 4)assert

9.Which of the following package is required for generating test reports in html format using nose?

  1. nose-reports
  2. htmloutput
  3. nose-htmloutput
  4. nose-html

Answer: 3)nose-htmloutput

10.Unittest Tests can be run using nose. State true or false.

  1. True
  2. False

Answer: 1)True

11.How many tests are run, when below code is tested using nose?

import unittest

def test_sample1():

    assert 3 == 3

class SampleTestClass(unittest.TestCase):

    def test_sample2(self):

        self.assertEqual(3, 3)

  1. 3
  2. 2
  3. 1
  4. 0

Answer: 2)2

12.How many tests of sample_module.py shown below, are successfully passed, when run with nose?

from nose.tools import raises

class SampleTestClass:

    @raises(TypeError)

    def test_sample1(self):

        pow(2, '4')

   @raises(Execption)

    def test_sample2(self):

        max([7, 8, '4'])

    @raises(Exception)

    def test_sample3(self):

        int('hello')

  1. 1
  2. 0
  3. 2
  4. 3

Answer: 2)0


Quiz on pytest


1.Which of the following command is used to discover all tests in a project and execute them using pytest?

  1. py.test
  2. pytests
  3. pytest
  4. py.tests

Answer: 1)py.test

2.Which of the following are the function level fixtures available in pytest?

  1. setUpFunction, tearDownFunction
  2. setup, teardown
  3. setupFunction, teardownFunction
  4. setup_function, teardown_function

Answer: 4)setup_function, teardown_function

3.How many tests are run, when below code is tested using pytest

import unittest

def test_sample1():

    assert 3 == 3

class SampleTestClass(unittest.TestCase):

    def test_sample2(self):

        self.assertEqual(3, 3)

  1. 1
  2. 2
  3. 0
  4. 3

Answer: 2)2

4.Which of the following decorator is used to skip a test unconditionally, with pytest?

  1. @pytest.mark.skip
  2. @pytest.mark.ignoreif
  3. @pytest.mark.skipif
  4. @pytest.mark.ignore

Answer: 1)@pytest.mark.skip

5.Which of the following decorator is used to transform a user defined function into a fixture using pytest?

  1. @pytest.fixtures
  2. @pytest.fixture
  3. @fixtures
  4. @pytest

Answer: 2)@pytest.fixture

6.Which of the following option is used to generate Junit style test report in xml using pytest?

  1. --junitxml
  2. --jxml
  3. --xml
  4. --junit

Answer: 1)--junitxml

7.pytest is capable of discovering and running tests written in unittest and nose. State true or false.

  1. False
  2. True

Answer: 2)True

8.pytest is available as a part of Python standard library. State true or false.

  1. True
  2. False

Answer: 2)False

9.Which of the following commands run only one test case, present in sample_module.py using pytest?

  1. py.test
  2. py.test sample_module.py
  3. py.test sample_module.py::TestCase1
  4. py.test sample_module.py::TestCase1::test_method1

Answer: 4)py.test sample_module.py::TestCase1::test_method1


Final Assessment on Unit Testing in Python


All Answers of Final Assessment Questions Present above. Use Ctrl + F to find the Question.


Post a Comment

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