1. Add a doctest test for your function add with two different numbers to add than...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. Add a doctest test for your function add with two different numbers to add than the numbers given in the examples. Make sure to use the symbols >>> and add the expected value afterward. Hint: If you can't figure out the expected value, run it with an empty expected value and see what the error says it should expect. 2. Add a doctest test for your function mult. 3. Write the regular expression pattern = that will match a username with: (eg. username = "tabby2x") a. Only alphanumeric characters 4. Write the regular expression pattern that will match a user id with: (eg. userid="12355") a. Only numeric characters 5. Write the regular expression pattern that will match both files and filed. 6. Write the regular expression pattern that will match three letter words that are preceded by a dot and space character. 7. Write the regular expression pattern that will match an email with: (eg. email='ex@ex.ex") a. At Least 1 alphabetic character before the at symbol b. Exactly 1 at symbol c. At Least 1 alphabetic character after the at symbol d. Exactly 1 period symbol e. At Least 1 alphabetic character after the period symbol (You need to escape this character). Google it to figure out how 8. Write a regex for matching telephone numbers Challenge: 1. Write the regular expression pattern that will match a password with: (eg. password = "a8e316$#"). The characters can be in any order a. At least 1 number b. At Least 1 alphabetic character. c. At Least 1 special character (1#$%&/) Doctest There are 4 important components of the documentation for functions in Python: Description Example (with a real argument and a real expected output) O The function call with the real argument has a >>> in front of it to tell doctype it is the expected output • Arguments Return def greet (name) : """Description: This function greets the person passed in as a parameter Examples for doctest >>> greet ("Kiki") Hello, Kiki. Good morning! 'Kiki' >>>greet (name="Jackie") Hello, Jackie. Good morning! 'Jackie' Argument: name, the name of the user to greet Return: name, So we can I save it for later print ("Hello, + return name "1 name + "1 # Use Doc Test doctest.testmod () Good morning!") 1. Add a doctest test for your function add with two different numbers to add than the numbers given in the examples. Make sure to use the symbols >>> and add the expected value afterward. Hint: If you can't figure out the expected value, run it with an empty expected value and see what the error says it should expect. 2. Add a doctest test for your function mult. 3. Write the regular expression pattern = that will match a username with: (eg. username = "tabby2x") a. Only alphanumeric characters 4. Write the regular expression pattern that will match a user id with: (eg. userid="12355") a. Only numeric characters 5. Write the regular expression pattern that will match both files and filed. 6. Write the regular expression pattern that will match three letter words that are preceded by a dot and space character. 7. Write the regular expression pattern that will match an email with: (eg. email='ex@ex.ex") a. At Least 1 alphabetic character before the at symbol b. Exactly 1 at symbol c. At Least 1 alphabetic character after the at symbol d. Exactly 1 period symbol e. At Least 1 alphabetic character after the period symbol (You need to escape this character). Google it to figure out how 8. Write a regex for matching telephone numbers Challenge: 1. Write the regular expression pattern that will match a password with: (eg. password = "a8e316$#"). The characters can be in any order a. At least 1 number b. At Least 1 alphabetic character. c. At Least 1 special character (1#$%&/) Doctest There are 4 important components of the documentation for functions in Python: Description Example (with a real argument and a real expected output) O The function call with the real argument has a >>> in front of it to tell doctype it is the expected output • Arguments Return def greet (name) : """Description: This function greets the person passed in as a parameter Examples for doctest >>> greet ("Kiki") Hello, Kiki. Good morning! 'Kiki' >>>greet (name="Jackie") Hello, Jackie. Good morning! 'Jackie' Argument: name, the name of the user to greet Return: name, So we can I save it for later print ("Hello, + return name "1 name + "1 # Use Doc Test doctest.testmod () Good morning!")
Expert Answer:
Answer rating: 100% (QA)
1 Doctest test for function add def addnum1 num2 Returns the sum of two numbers Example add2 3 5 add... View the full answer
Related Book For
Managerial Accounting An Integrative Approach
ISBN: 9780999500491
2nd Edition
Authors: C J Mcnair Connoly, Kenneth Merchant
Posted Date:
Students also viewed these programming questions
-
Olivia has $200,000 deposited today (at t = 0) in an account at the Nashua Savings Bank which pays an annual interest rate of 4.4%. If starting next year (at t = 1) she wants to start making 6 annual...
-
You are required to write a Python program that will manage character (heroes and villain) information. Character (hero and villain) information will be stored in a text file that will be read in...
-
For the following exercises, you will address problems and answer questions from management at TAL Distributors. You do not use the TAL Distributors database for any of these exercises. 1. While...
-
A dam across a Maine river is going to be dismantled. Its original dimensions above the water on the downriver side of the dam are shown below. On the upriver side of the dam, the water level reaches...
-
Electric solar cells can produce power with 15% efficiency. Compare that to a heat engine driving an electric generator with 80% efficiency. What should the heat engine efficiency be to have the same...
-
The 2008 balance sheet of Maria's Tennis Shop, Inc., showed long-term debt of $2.6 million, and the 2009 balance sheet showed long-term debt of $2.9 million. The 2009 income statement showed an...
-
With reference to Exercise 11.39, use the theory of the preceding exercise to calculate the multiple correlation coefficient (which measures how strongly the current gain is related to the two...
-
How should Easterbrook adapt the organizational structure of McDonald's to achieve his strategic plan?
-
6. Explain in detail why 8086 supports a maximum of 1MB physical memory? (2 mark) 7. What will be the capacity in megabytes of the physical memory of a microprocessor with a 28 bit address bus? What...
-
Again, if only group classes were offered, assuming that all of the costs associated with the running of group classes (including teachers' wages) are fixed costs, and using the maximum rent, average...
-
Suppose a bond has a $1,000 face value and a coupon interest rate of 6% per year. This bond promises to pay $60 (6% $1,000) each year, plus $1,000 when the bond matures in 2 years. If the market...
-
A firm's management wants to improve its cash flows with regard to working capital and wants to reflect this priority in its annual budget. What is an appropriate plan of action?
-
What is the most effective mechanism that promotes vasoconstriction after an injury? Explain
-
Pearson Dental needs to purchase new laser dental equipment. The dental practice is seeking 85,000 for 5 years at a fixed rate of interest. This is an example of what type of credit arrangement with...
-
Prepare journal entries to record the following transactions. Purchased $390 of supplies on credit. Completed $590 of work for a client on credit. Paid $390 cash towards the amount owed from...
-
The axially loaded member shown in Figure a has a cross-section as shown in Figure b. Using Fy-50 ksi, determine the design strength, fcPn, for this member. | fcPn L=20 ft | 20" Lacing 4L - 6x6x1 20"
-
? e particle in mowing in one dimension is in a Itationary Gate eut cas meus Lunction Y(2) = x Q. echere A and a are creal Constant 2) Is this is a physical exceptable exare function b) find A. c)...
-
Briefly discuss the implications of the financial statement presentation project for the reporting of stockholders equity.
-
How are balanced scorecards used in the product domain?
-
In this exercise, you are going to take the answers you derived for DB 13.2 and use this information to cost out the work done for individual customers during the year. You will need the following...
-
Define the three different types of cost drivers and give examples of each.
-
Light of wavelength \(\lambda\) is incident on an aperture of width \(a\), producing diffraction. Describe the change(s) in the diffracted waves \((a)\) when the aperture width is doubled and \((b)\)...
-
Which wavelength of electromagnetic radiation do you expect to be diffracted by a window screen? What is the frequency of this radiation?
-
Name some characteristics that allow you to observe light diffraction.
Study smarter with the SolutionInn App