<< 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 defense mechanism
Chinaza Reply
what is defense mechanisms
Chinaza
I'm interested in biological psychology and cognitive psychology
Tanya Reply
what does preconceived mean
sammie Reply
physiological Psychology
Nwosu Reply
How can I develope my cognitive domain
Amanyire Reply
why is communication effective
Dakolo Reply
Communication is effective because it allows individuals to share ideas, thoughts, and information with others.
effective communication can lead to improved outcomes in various settings, including personal relationships, business environments, and educational settings. By communicating effectively, individuals can negotiate effectively, solve problems collaboratively, and work towards common goals.
it starts up serve and return practice/assessments.it helps find voice talking therapy also assessments through relaxed conversation.
miss
Every time someone flushes a toilet in the apartment building, the person begins to jumb back automatically after hearing the flush, before the water temperature changes. Identify the types of learning, if it is classical conditioning identify the NS, UCS, CS and CR. If it is operant conditioning, identify the type of consequence positive reinforcement, negative reinforcement or punishment
Wekolamo Reply
please i need answer
Wekolamo
because it helps many people around the world to understand how to interact with other people and understand them well, for example at work (job).
Manix Reply
Agreed 👍 There are many parts of our brains and behaviors, we really need to get to know. Blessings for everyone and happy Sunday!
ARC
A child is a member of community not society elucidate ?
JESSY Reply
Isn't practices worldwide, be it psychology, be it science. isn't much just a false belief of control over something the mind cannot truly comprehend?
Simon Reply
compare and contrast skinner's perspective on personality development on freud
namakula Reply
Skinner skipped the whole unconscious phenomenon and rather emphasized on classical conditioning
war
explain how nature and nurture affect the development and later the productivity of an individual.
Amesalu Reply
nature is an hereditary factor while nurture is an environmental factor which constitute an individual personality. so if an individual's parent has a deviant behavior and was also brought up in an deviant environment, observation of the behavior and the inborn trait we make the individual deviant.
Samuel
I am taking this course because I am hoping that I could somehow learn more about my chosen field of interest and due to the fact that being a PsyD really ignites my passion as an individual the more I hope to learn about developing and literally explore the complexity of my critical thinking skills
Zyryn Reply
good👍
Jonathan
and having a good philosophy of the world is like a sandwich and a peanut butter 👍
Jonathan
generally amnesi how long yrs memory loss
Kelu Reply
interpersonal relationships
Abdulfatai 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