<< Chapter < Page Chapter >> Page >
Figure 33 . Question 9 possible output.
Trying: divide(1,3)Expecting: 0.3333333333333333ok 1 items had no tests:__main__.divide 1 items passed all tests:1 tests in __main__ 1 tests in 2 items.1 passed and 0 failed. Test passed.

Go to answer 9

Figure index

  • Figure 1 . Question 1 test code named Py1359_1720r_01.txt.
  • Figure 2 . Question 1 execution command.
  • Figure 3 . Question 1 possible output.
  • Figure 4 . Question 1 actual output.
  • Figure 5 . Question 2 test code named Py1359_1720r_02.txt.
  • Figure 6 . Question 2 execution command.
  • Figure 7 . Question 2 possible output.
  • Figure 8 . Question 2 actual output.
  • Figure 9 . Question 3 Python module named Py1359_1720r_03.py.
  • Figure 10 . Question 3 test code named Py1359_1720r_03.txt.
  • Figure 11 . Question 3 execution command.
  • Figure 12 . Question 3 possible output.
  • Figure 13 . Question 4 Python module named Py1359_1720r_04.py.
  • Figure 14 . Question 4 execution command.
  • Figure 15 . Question 4 possible output.
  • Figure 16 . Question 5 Python module named Py1359_1720r_05.py.
  • Figure 17 . Question 5 execution command.
  • Figure 18 . Question 5 possible output.
  • Figure 19 . Question 6 Python module named Py1359_1720r_06.py.
  • Figure 20 . Question 6 execution command.
  • Figure 21 . Question 6 possible output.
  • Figure 22 . Question 7 Python module named Py1359_1720r_07_runner.py.
  • Figure 23 . Question 7 Python module named Py1359_1720r_07.py.
  • Figure 24 . Question 7 execution command.
  • Figure 25 . Question 7 test code named Py1359_1720r_07.txt.
  • Figure 26 . Question 7 possible output.
  • Figure 27 . Question 8 Python module named Py1359_1720r_08.py.
  • Figure 28 . Question 8 test code named Py1359_1720r_08.txt.
  • Figure 29 . Question 8 execution command.
  • Figure 30 . Question 8 possible output.
  • Figure 31 . Question 9 Python module named Py1359_1720r_09.py.
  • Figure 32 . Question 9 execution command.
  • Figure 33 . Question 9 possible output.
  • Figure 34 . Question 9 actual output.

What is the meaning of the following two images?

These images were inserted here simply to insert some space between the questions and the answers to keep them from being visible on the screen at thesame time.

Spacer image of a rabbit and a penguin.

This image was also inserted for the purpose of inserting space between the questions and the answers.

Spacer image of a penguin and some houses.

Answers

Answer 9

False. The actual output is shown in Figure 34 . This question was included topoint out that testing floating point results can be problematic. Many floating point values are simply estimates. Although this example was purposely caused tofail, a given floating point computation may not produce exactly the same results on different platforms. Therefore a test that specifies a given floatingpoint result may pass on one platform and fail on a different platform. The Python Standard Library -- 26.2 doctest -- Test interactive Python examples provides some suggestions for dealing with this issue.

Figure 34 . Question 9 actual output.
Trying: divide(1,3)Expecting: 0.333333********************************************************************** File "Py1359_1720r_09.py", line 4, in __main__Failed example: divide(1,3)Expected: 0.333333Got: 0.33333333333333331 items had no tests: __main__.divide********************************************************************** 1 items had failures:1 of 1 in __main__ 1 tests in 2 items.0 passed and 1 failed. ***Test Failed*** 1 failures.

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