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)
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 ____________.
- Test Development
- Test Focussed Development
- Test Driven Development
- Test Preferred Development
Answer: 3)Test Driven Development
2.Which type of testing is performed to check if a program is behaving as expected?
- unit testing
- regression testing
- system testing
- acceptance testing
Answer: 4)acceptance testing
3.Which of the following are the unit testing packages availabale in Python?
- pytest
- All of those Mentioned
- doctest
- nose
- unittest
Answer: 2)All of those Mentioned
4.The testing method, which is used to test individual components of a program is known as ________.
- unit testing
- system testing
- regression testing
- acceptance testing
Answer: 1)unit testing
5.Which type of testing is done when one of your existing functions stop working?
- unit testing
- regression testing
- acceptance testing
- system testing
Answer: 2)regression testing
6.Unit Testing is the highest level of testing. State true or false.
- True
- False
Answer: 2)False
7.The real objective of Software testing is to ensure 100% defect free product. State true or false.
- True
- False
Answer: 2)False
8.Which of the following is the next level of testing to unit testing?
- Acceptance testing
- Integration testing
- system testing
- 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 __________.
- Software Testing
- Software Diagnosis
- Software Evaluation
- Software Debugging
Answer: 1)Software Testing
10.Why Software Testing is necessary?
- It makes software reliable and user friendly
- It reduces cost by detecting bugs in early stage of development
- All of those mentioned
- It ensure quality of product
Answer: 3)All of those mentioned
- List of Fresco Play Courses without Hands-On | Fresco Play
- HMTL5 Semantics Elements MCQs Answers | Fresco Play
- HMTL5 Semantics Elements Hands-On Solutions | Fresco Play
- Styling with CSS3 Hands-On Solutions | Fresco Play
- Blockchain Intermedio MCQs Answers | Fresco Play
- Blockchain - Potentes Nexus MCQs Answers | Fresco Play
- Azure Essentials MCQs Answers | Fresco Play
- AWS Essentials MCQs Answers | Fresco Play
Quiz on doctest
1.Which of the following is true about a docstring?
- docstring is a single lie string.
- docstring is a document
- docstring is optional in a function, class or a module
- 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?
-
def add(x, y):
"""Returns sum of two numbers.
"""
>>> add(5, 6)
13
return x + y
-
def add(x, y):
return x + y
-
def add(x, y):
"""Returns sum of two numbers.
>>> add(5, 6)
13
"""
return x + y
-
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
- No output
- Output stating 2 tests passed
- Output stating 1 test passed
- 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?
- __docstr__
- __str__
- __doc__
- __document__
Answer: 3)__doc__
5.Which of the following doctest directive is used to ignore part of the result?
- # doctest: +IGNORE
- # doctest: +COMMENT
- # doctest: +ELLIPSIS
- # 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?
-
>>> sample_func(6, 7)
6
BLANKLINE
7
BLANKLINE
42
-
>>> sample_func(6, 7)
6
<BLANKLINE>
7
<BLANKLINE>
42
-
>>> sample_func(6, 7)
6
<blankline>
7
<blankline>
42
-
>>> 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?
- A Function
- A Class
- A Multiline string
- 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?
- # doctest: +WHITE_SPACE
- # doctest: +NORMALIZE_WHITE_SPACE
- # doctest: +NORMALIZE_WHITESPACE
- # 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
- Output stating 2 failures
- Output stating 2 tests passed
- Output stating 3 tests passed
- 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?
- # doctest: +IGNORE
- # doctest: +ERASE
- # doctest: +SKIP
- # doctest: +NEGLECT
Answer: 3)# doctest: +SKIP
11.A doctest mixes documentation and testing. State true or false.
- True
- False
Answer: 1)True
Quiz on unittest
1.unittest is a xUnit-style based unit testing framework in Python. State true or false.
- True
- False
Answer: 1)True
2.Which of the following decorator is used to skip a test if a given condition is false, with unittest?
- unittest.skipUnless
- unittest.skipIf
- unittest.skipUntil
- 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
- 3
- 0
- 2
Answer: 1)1
4.Which of the following is not a component of Xunit-Style Architecture?
- Test runner
- Test Loader
- Assertions
- 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?
- python -m unittest
- python -m unittest test
- python -m unittest start
- 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?
- assertRegexpMatches
- assertSearch
- assertMatch
- 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')
- 0
- 3
- 1
- 2
Answer: 1)0
8.Which of the following decorator need to be used while working with setUpClass and tearDownClass fixtures?
- @classfixture
- @testclass
- @classtest
- @classmethod
Answer: 4)@classmethod
9.Which of the following commands run only one test case , present in sample_module.py using unittest?
- python -m unittest sample_module.TestCase1
- python -m unittest sample_module.TestCase1.test_method1
- python -m unittest sample_module
- 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?
- self.id returns the name of method
- self.id returns reference value
- self.id returns the name of module
- 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.
- False
- True
Answer: 2)True
12.Which of the following method is used to catch exceptions in a test, with unittest?
- assertException
- assertRaises
- assertCatch
- 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)
-
Entering Test Class
.
Exiting Test Class -
Entering Test Class
.Exiting Test Class - The test run fails.
-
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?
- assertList
- assertEqual
- assertListEqual
- 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
- unittest.main
- unittest.discover
- unittest.test
- 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')
- 2
- 3
- 0
- 1
Answer: 3)0
17.A single test module contains only one Test Class. State true or false.
- False
- True
Answer: 1)False
18.What is the parent class from which a Test class has to be derived for running it with unittest?
- unittest.unittest
- unittest.ParentCase
- unittest.Parent
- 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?
- python -m unittest
- python -m unittest start
- python -m unittest test
- 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?
- --xml
- --with-unit
- --with-xunit
- --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?
- @setup
- @use_setup
- @use
- @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
- False
- True
Answer: 2)True
4.nose supports use of fixtures at package level. State true or false.
- True
- False
Answer: 1)True
5.Which of the following command is used to discover all tests in a project and execute them using nose?
- python nosetests
- nosetests
- python nose
- 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?
- @timeit
- @time
- @timecheck
- @timed
Answer: 4)@timed
7.Test discovery is simpler in unittest than in nose. State true or false.
- True
- False
Answer: 2)False
8.ok_ utility from nose.tools is equivalent to ____________.
- assert_equal
- assert_equals
- assert_same
- assert
Answer: 4)assert
9.Which of the following package is required for generating test reports in html format using nose?
- nose-reports
- htmloutput
- nose-htmloutput
- nose-html
Answer: 3)nose-htmloutput
10.Unittest Tests can be run using nose. State true or false.
- True
- 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)
- 3
- 2
- 1
- 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
- 0
- 2
- 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?
- py.test
- pytests
- pytest
- py.tests
Answer: 1)py.test
2.Which of the following are the function level fixtures available in pytest?
- setUpFunction, tearDownFunction
- setup, teardown
- setupFunction, teardownFunction
- 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
- 2
- 0
- 3
Answer: 2)2
4.Which of the following decorator is used to skip a test unconditionally, with pytest?
- @pytest.mark.skip
- @pytest.mark.ignoreif
- @pytest.mark.skipif
- @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?
- @pytest.fixtures
- @pytest.fixture
- @fixtures
- @pytest
Answer: 2)@pytest.fixture
6.Which of the following option is used to generate Junit style test report in xml using pytest?
- --junitxml
- --jxml
- --xml
- --junit
Answer: 1)--junitxml
7.pytest is capable of discovering and running tests written in unittest and nose. State true or false.
- False
- True
Answer: 2)True
8.pytest is available as a part of Python standard library. State true or false.
- True
- False
Answer: 2)False
9.Which of the following commands run only one test case, present in sample_module.py using pytest?
- py.test
- py.test sample_module.py
- py.test sample_module.py::TestCase1
- 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.
- List of Fresco Play Courses without Hands-On | Fresco Play
- HMTL5 Semantics Elements MCQs Answers | Fresco Play
- HMTL5 Semantics Elements Hands-On Solutions | Fresco Play
- Styling with CSS3 Hands-On Solutions | Fresco Play
- Blockchain Intermedio MCQs Answers | Fresco Play
- Blockchain - Potentes Nexus MCQs Answers | Fresco Play
- Azure Essentials MCQs Answers | Fresco Play
- AWS Essentials MCQs Answers | Fresco Play