<< Chapter < Page Chapter >> Page >
Figure 20 . Question 6 execution command.
python Py1359_1720r_06.py -v
Figure 21 . Question 6 possible output.
Trying: function(11)Expecting: Traceback (most recent call last):... ValueError: par must be<= 10 ok1 items had no tests: __main__.function1 items passed all tests: 1 tests in __main__1 tests in 2 items. 1 passed and 0 failed.Test passed.

Go to answer 6

Question 7

True or False? Given the Python modules shown in Figure 22 and Figure 23 and the test file shown in Figure 25 , execution of the command shown in Figure 24 , produces the output shown in Figure 26 .

Figure 22 . Question 7 Python module named Py1359_1720r_07_runner.py.
import doctest doctest.testfile(Py1359_1720r_07.txt)
Figure 23 . Question 7 Python module named Py1359_1720r_07.py.
def sum(parA,parB): return parA + parBdef product(parC,parD): return parC * parD
Figure 24 . Question 7 execution command.
python Py1359_1720r_07_runner.py
Figure 25 . Question 7 test code named Py1359_1720r_07.txt.
>>>from Py1359_1720r_07 import sum>>>sum(2,3) 5>>>from Py1359_1720r_07 import product>>>product(2,3) 5
Figure 26 . Question 7 possible output.
********************************************************************** File "Py1359_1720r_07.txt", line 5, in Py1359_1720r_07.txtFailed example: product(2,3)Expected: 5Got: 6********************************************************************** 1 items had failures:1 of 4 in Py1359_1720r_07.txt ***Test Failed*** 1 failures.

Go to answer 7

Question 8

True or False? Given the Python module shown in Figure 27 and the test file shown in Figure 28 , execution of the module as a script using the command shown in Figure 29 , produces the output shown in Figure 30 .

Figure 27 . Question 8 Python module named Py1359_1720r_08.py.
def sum(parA,parB): return parA + parBdef product(parC,parD): return parC * parDif __name__ == "__main__": import doctestdoctest.testfile("Py1359_1720r_08.txt")
Figure 28 . Question 8 test code named Py1359_1720r_08.txt.
>>>from Py1359_1720r_08 import sum>>>sum(2,3) 5>>>from Py1359_1720r_08 import product>>>product(2,3) 6
Figure 29 . Question 8 execution command.
python Py1359_1720r_08.py -v
Figure 30 . Question 8 possible output.
Trying: from Py1359_1720r_08 import sumExpecting nothing okTrying: sum(2,3)Expecting: 5ok Trying:from Py1359_1720r_08 import product Expecting nothingok Trying:product(2,3) Expecting:6 ok1 items passed all tests: 4 tests in Py1359_1720r_08.txt4 tests in 1 items. 4 passed and 0 failed.Test passed.

Go to answer 8

Question 9

True or False? Given the Python version 3 module shown in Figure 31 , execution of the module as a script using the command shown in Figure 32 , produces the output shown in Figure 33 .

Figure 31 . Question 9 Python module named Py1359_1720r_09.py.
""">>>divide(1,3) 0.333333""" def divide(parA,parB):return parA/parB if __name__ == "__main__":import doctest doctest.testmod()
Figure 32 . Question 9 execution command.
python Py1359_1720r_09.py -v

Questions & Answers

what is biology
Hajah Reply
the study of living organisms and their interactions with one another and their environments
AI-Robot
what is biology
Victoria Reply
HOW CAN MAN ORGAN FUNCTION
Alfred Reply
the diagram of the digestive system
Assiatu Reply
allimentary cannel
Ogenrwot
How does twins formed
William Reply
They formed in two ways first when one sperm and one egg are splited by mitosis or two sperm and two eggs join together
Oluwatobi
what is genetics
Josephine Reply
Genetics is the study of heredity
Misack
how does twins formed?
Misack
What is manual
Hassan Reply
discuss biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles
Joseph Reply
what is biology
Yousuf Reply
the study of living organisms and their interactions with one another and their environment.
Wine
discuss the biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles in an essay form
Joseph Reply
what is the blood cells
Shaker Reply
list any five characteristics of the blood cells
Shaker
lack electricity and its more savely than electronic microscope because its naturally by using of light
Abdullahi Reply
advantage of electronic microscope is easily and clearly while disadvantage is dangerous because its electronic. advantage of light microscope is savely and naturally by sun while disadvantage is not easily,means its not sharp and not clear
Abdullahi
cell theory state that every organisms composed of one or more cell,cell is the basic unit of life
Abdullahi
is like gone fail us
DENG
cells is the basic structure and functions of all living things
Ramadan
What is classification
ISCONT Reply
is organisms that are similar into groups called tara
Yamosa
in what situation (s) would be the use of a scanning electron microscope be ideal and why?
Kenna Reply
A scanning electron microscope (SEM) is ideal for situations requiring high-resolution imaging of surfaces. It is commonly used in materials science, biology, and geology to examine the topography and composition of samples at a nanoscale level. SEM is particularly useful for studying fine details,
Hilary
cell is the building block of life.
Condoleezza Reply
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

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