<< Chapter < Page Chapter >> Page >
This module contains review questions and answers keyed to the module titled Itse1359-1720-Doctest as well as review questions and answers keyed to the document at https://docs.python.org/3/library/doctest.html.

Table of contents

Preface

This module is one in a collection of modules on Python designed for teaching ITSE 1359 Introduction to Scripting Languages: Python at Austin Community College in Austin, TX.

This module contains review questions and answers keyed to the module titled Itse1359-1720-Doctest . In addition, some of the questions and answers are keyed to the document titled The Python Standard Library -- 26.2 doctest -- Test interactive Python examples .

Once you study that material, you should be able to answer the review questions in this module.

The questions and the answers in this module are connected by hyperlinks to make it easy for you to navigate from the question to the answer and back again.

(Note to blind and visually impaired students: with the exception of two bitmap images that are used solely as spacers to separate the questionsection from the answer section, all of the material in this module is presented in plain text format and should be accessible using an audio screen reader or abraille display. Note however that the required indentation may not be properly represented by an audio screen reader.)

Questions

Question 1

True or False? The test file shown in Figure 1 , when executed using the command shown in Figure 2 , produces the output shown in Figure 3 .

Figure 1 . Question 1 test code named Py1359_1720r_01.txt.
Beginning of first test>>>2 + 3 5End of first test Beginning of second test>>>2 + 3 6End of second test
Figure 2 . Question 1 execution command.
python -m doctest Py1359_1720r_01.txt
Figure 3 . Question 1 possible output.
********************************************************************** File "Py1359_1720r_01.txt", line 2, in Py1359_1720r_01.txtFailed example: 2 + 3Expected: 6Got: 5********************************************************************** File "Py1359_1720r_01.txt", line 7, in Py1359_1720r_01.txtFailed example: 2 + 3Expected: 6Got: 5********************************************************************** 1 items had failures:2 of 2 in Py1359_1720r_01.txt ***Test Failed*** 2 failures.

Go to answer 1

Question 2

True or False? The test file shown in Figure 5 , when executed using the command shown in Figure 6 , produces the output shown in Figure 7 .

Figure 5 . Question 2 test code named Py1359_1720r_02.txt.
Beginning of test>>>2 + 3 5End of test
Figure 6 . Question 2 execution command.
python -m doctest Py1359_1720r_02.txt -v
Figure 7 . Question 2 possible output.
Trying: 2 + 3Expecting: 5ok 1 items passed all tests:1 tests in Py1359_1720r_02.txt 1 tests in 1 items.1 passed and 0 failed. Test passed.

Go to answer 2

Question 3

True or False? Given the Python module shown in Figure 9 , when the test file shownin Figure 10 is executed using the command shown in Figure 11 , it produces theoutput shown in Figure 12 .

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Itse 1359 introduction to scripting languages: python. OpenStax CNX. Jan 22, 2016 Download for free at https://legacy.cnx.org/content/col11713/1.32
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Itse 1359 introduction to scripting languages: python' conversation and receive update notifications?

Ask