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
-
"internet radios" for streaming audio, and personal video recorders and players. Describe design and evaluation processes that could be used by a start-up company to improve the usability of such...
-
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...
-
Verizon Communications Inc. is a major telecommunications company in the United States. Two recent balance sheets for Verizon disclosed the following information regarding fixed assets: Verizon's...
-
During its final approach to the runway, the aircraft speed is reduced from 300 km / h at A to 200 km / h at B. Determine the net external aerodynamic force R which acts on the 200-Mg aircraft during...
-
True or False: If \(P W>0\), then \(I R R>M A R R\).
-
A completed worksheet for The King Group is shown on the bottom of these two pages. INSTRUCTIONS 1. Record balances as of December 31, 2016, in the ledger accounts. 2. Journalize (use 3 as the page...
-
An aluminum-alloy rod has a length of 9.2293 cm at 20.00C and a length of 9.2767 cm at the boiling point of water. (a) What is the length of the rod at the freezing point of water? (b) What is the...
-
There are 6 independent research studies. each sample size is 29 significance level of alpha is 0.08. suppose the test is an upper tail test and the null hypothesis is True what is the probability...
-
Explain what is meant by extra-sensory perception.
-
What is the present value of $13,000 received a. Ten years from today when the interest rate is 4% per year? b. Twenty years from today when the interest rate is 8% per year? c. Five years from today...
-
How does one go about tackling the problems of appraisal?
-
Examine some adverse repercussions likely to arise from perceptual errors or misperceptions.
-
Suppose your firm receives a $4.1 million order on the last day of the year. You fill the order with $2.9 million worth of inventory. The customer picks up the entire order the same day and pays $1.5...
-
A beam of 8.0-MeV a particles scatters from a thin gold foil. What is the ratio of the number of a particles scattered to angles greater than 1 to the number scattered to angles greater than 2?
-
A bar of a steel alloy that exhibits the stress-strain behavior shown in Figure 6.22 is subjected to a tensile load; the specimen is 375 mm (14.8 in.) long and has a square cross section 5.5 mm (0.22...
-
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.
-
Why may some people consider this to be incorrect? That is, why is the fact that the control account is kept in the General Ledger not enough to justify saying that the control account is part of the...
-
From the following figures, compile accounts receivable ledger and accounts payable ledger control accounts for the month, and ascertain what the net balances of the respective ledgers should be on...
-
The financial year of The Better Trading Company ended on 30 November 2014. You have been asked to prepare a Total Accounts Receivable Account and a Total Accounts Payable Account in order to produce...
Study smarter with the SolutionInn App