You will now implement the behaviour for a !divide chatbot command. For this command, you may...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
You will now implement the behaviour for a !divide chatbot command. For this command, you may assume that the user always provides two numbers, for example !divide 1.5 5. Like the previous task, you only need to define the function and we will worry about accepting user input later. Hint: The payload argument for all of the chatbot commands will always be a list of strings. For the bot_divide() function specifically, the first element of this list will be the numerator (as a string) and the second element will be the denominator (as a string). In order to perform division, you will need to convert these elements to another type. When it comes to displaying the result, the chatbot must show the full equation with the answer inside it. not just the answer. The numerator and denominator must be displayed exactly as the user typed them, and the answer must be displayed to 4 decimal places. So, if the user wants to divide 10.00 by 2, then the full chatbot output should be 10.00/2 = 5.0000. Examples for testing Use the examples below, as well as your own examples, to test your code. The output from your chatbot should exactly match what is shown here. bot divide(['1.5', '5']) Chatbot: 1.5/5 = 0.3000 bot divide(['10.00', '2']) Chatbot: 10.00/2 5.0000 bot divide(['3', '7.0']) Chatbot: 3/7.0 0.4286 Criteria Uses data from the payload to determine the numerator and denominator of the division. (3 marks) Performs division using an appropriate expression. (1 mark) Converts elements in the payload to an appropriate type. (2 marks) Displays the result as an equation using the bot say() function. (2 marks) Displays the numerator and denominator in the output exactly as the user typed them, but the answer to 4 decimal places (see examples). (2 marks) You will now implement the behaviour for a !divide chatbot command. For this command, you may assume that the user always provides two numbers, for example !divide 1.5 5. Like the previous task, you only need to define the function and we will worry about accepting user input later. Hint: The payload argument for all of the chatbot commands will always be a list of strings. For the bot_divide() function specifically, the first element of this list will be the numerator (as a string) and the second element will be the denominator (as a string). In order to perform division, you will need to convert these elements to another type. When it comes to displaying the result, the chatbot must show the full equation with the answer inside it. not just the answer. The numerator and denominator must be displayed exactly as the user typed them, and the answer must be displayed to 4 decimal places. So, if the user wants to divide 10.00 by 2, then the full chatbot output should be 10.00/2 = 5.0000. Examples for testing Use the examples below, as well as your own examples, to test your code. The output from your chatbot should exactly match what is shown here. bot divide(['1.5', '5']) Chatbot: 1.5/5 = 0.3000 bot divide(['10.00', '2']) Chatbot: 10.00/2 5.0000 bot divide(['3', '7.0']) Chatbot: 3/7.0 0.4286 Criteria Uses data from the payload to determine the numerator and denominator of the division. (3 marks) Performs division using an appropriate expression. (1 mark) Converts elements in the payload to an appropriate type. (2 marks) Displays the result as an equation using the bot say() function. (2 marks) Displays the numerator and denominator in the output exactly as the user typed them, but the answer to 4 decimal places (see examples). (2 marks)
Expert Answer:
Related Book For
Introduction to Algorithms
ISBN: 978-0262033848
3rd edition
Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest
Posted Date:
Students also viewed these operating system questions
-
Q1. You have identified a market opportunity for home media players that would cater for older members of the population. Many older people have difficulty in understanding the operating principles...
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
A saving bond earns a variable rate of interest that can change six months, with compounding done monthly. The initial rate was 6.8% in early 2015. If that rate continues unchanged for the 3 years of...
-
Amazon.com, Inc. is the world's leading Internet retailer of merchandise and media. Amazon also designs and sells electronic products, such as e-readers. Netflix, Inc. is the world's leading Internet...
-
A package delivery company provides both overnight and second-day delivery services. It charges almost twice as much to deliver an overnight package to any world location as it does to deliver the...
-
During 2009, Newfoundland Corp. earned income from continuing operations of \(\$ 135,000\). The company also sold a segment of the business (discontinued operations) at a loss of \(\$ 30,000\) and...
-
Performance Tires plans to engage in direct mail advertising. It is currently in negotiations to purchase a mailing list of the names of people who bought sports cars within the last three years. The...
-
The temperature of coffee sold at the Coffee Bean Cafe follows the normal probability distribu- tion, with a mean of 150 degrees. The standard deviation of this distribution is 5 degrees. (a) What is...
-
Are for-profit organizations are allowed to use one depreciation method for the financial statements submitted to stockholders and another depreciation method for reporting to the IRS?
-
Comment on the advantages and disadvantages of using athlete endorsers in advertising.
-
When is personal selling used by sports marketers? Describe, in detail, the steps in the strategic selling process.
-
Describe how an athletes image has an impact upon brand development.
-
Outline the steps for designing a sports sponsorship program.
-
What are the characteristics of the total product?
-
Using trigonometric substitution, the f dx can be transformed to A. S cos?0d0 B. S tan? Odo c. S sin? Od0 D. S sec?0d0
-
From a medical tourist perspective, compare Shouldice with the traditional hospital in terms of the key factors of competition. Using Table 15-3, why would Shouldice attract patients from outside the...
-
Let X be a nonnegative random variable, and suppose that E [X] is well defined. Prove Markov?s inequality: Pr {X > t} < E [X]/t
-
Suppose that at some point in the execution of a push-relabel algorithm, there exists an integer 0 < k |V| 1 for which no vertex has .h = k. Show that all vertices with .h > k are on the source...
-
Prove that if a | b and b | c, then a | c.
-
Show how the Mohr's circles in Figure 2.17 can be used to interpret the transformed lamina stiffness \(\bar{Q}_{12}\). FIGURE 2.17 40 'n Q11 In- n> Q11 20 -U-
-
Using the results of Problem 2.6, determine the invariants \(U_{i}\) and \(V_{i}\) for the AS/3501 lamina, where \(i=1,2,3,4\). Problem 2.6 Find all components of the stiffness and compliance...
-
Using the results of Problem 2.6 or Problem 2.16, compare the transformed lamina stiffnesses for AS/3501 carbon/epoxy plies oriented at \(+45^{\circ}\) and \(-45^{\circ}\). Problem 2.6 Using the...
Study smarter with the SolutionInn App