Selector Next we will write a function that will help us select an output for the chatbot, based on the input it got.
The overall goal of this function is to take a list of words that we got as input, a list of words to check for if they appear in the input outputs to return if something from the list to check is in the input list.
Define a function, called selector.
This function should have the following inputs, outputs and internal procedures:
Input(s)
input_list - list of string
check_list - list of string
return_list - list of string
Output(s):
output - string, or None
Procedure(s):
Initialize output to None
Loop through each element in input_list
Use a conditional to check if the current element is in check_list
If it is, assign output as the returned value of calling the random.choice function on return_list
Also, break out of the loop
At the end of the function, return output Note that if we don't find any words from input_list that are in check_list, output will be returned as None.

Answers

Answer 1
Answer:

Answer:

See explaination

Explanation:

# Import required the module.

import random

# Define a function selector() which accepts the

# input_list, check_list, and return_list and

# returns a string named output.

def selector(input_list,check_list,return_list):

# Assign None to string variable output.

output=None

# Use for loop to traverse through input_list.

for i in range(len(input_list)):

# Check if element of an input_list is present

# in check_list.

if input_list[i] in check_list:

# Assign a random value from return_list

# to output.

output=random.choice(return_list)

# break out of the loop if input_list

# element is present in check_list.

break

#

return output

# Use assert statement to test a condition.

# If the condition is true, then program continues to

# execute, otherwise raises an AssertionError.

assert callable(selector)

assert selector(['is','in','of'],['of'], ['Yes']) == 'Yes'

assert selector(['is','in'],['of'], ['Yes','No']) == None

# Display the output.

print(selector(['is','in','of'],['of'], ['Yes']))

print(selector(['is','in'],['of'], ['Yes','No']))


Related Questions

A user logging on, an application server connecting to a database server, an authentication server rejecting a password, or an antivirus scanner reporting a suspected virus are all examples of:
Which orientation is wider than it is tall?PortraitMacroShutterLandscape
True / FalseIn the structure of a conventional processor, the computational engine is generally known as the arithmetic-logic unit.
How do you calculate the total resistance in a series circuit with more than one resistor?
Which tool, Wireshark or NetWitness, provides information about the wireless antenna strength during a captured transmission?

Select the correct answer. Which decimal number is equivalent to this binary number? 11111011

Answers

The decimal number which is equivalent to binary number 11111011 is 251.

Binary numbers are base-2 numbers, which means they are composed of only two digits: 0 and 1.

Each digit in a binarynumber represents a power of 2, starting from the rightmost digit.

The rightmost digit represents 2⁰ (which is 1), the next digit represents 2¹(which is 2), the next represents 2² (which is 4), and so on.

Given the binary number 11111011:

1 × 2⁷ + 1 × 2⁶ + 1 × 2⁵ + 1 × 2⁴ + 1 × 2³ + 0 × 2² + 1 × 2¹ + 1 × 2⁰

Simplifying each term:

128 + 64 + 32 + 16 + 8 + 0 + 2 + 1

= 251

Hence, 251 is the decimalnumber which is equivalent to binary number 11111011.

To learn more on Binary numbers click here:

brainly.com/question/31102086

#SPJ3

Answer:

251

Explanation:

Residential and business customers are paying different rates for water usage. Residential customers pay $0.005 per gallon for the first 6000 gallons. If the usage is more than 6000 gallons, the rate will be $0.007 per gallon after the first 6000 gallons. Business customers pay $0.006 per gallon for the first 8000 gallons. If the usage is more than 8000 gallons, the rate will be $0.008 per gallon after the first 8000 gallons. For example, a residential customer who has used 9000 gallons will pay $30 for the first 6000 gallons ($0.005 * 6000), plus $21 for the other 3000 gallons ($0.007 * 3000). The total bill will be $51. A business customer who has used 9000 gallons will pay $48 for the first 8000 gallons ($0.006 * 8000), plus $8 for the other 1000 gallons ($0.008 * 1000). The total bill will be $56. Write a program to do the following. Ask the user which type the customer it is and how many gallons of water have been used. Calculate and display the bill.

Answers

Answer:

// here is program in Java.

// import package

import java.util.*;

// class definition

class Main

{

   // main method of the class

public static void main (String[] args) throws java.lang.Exception

{

   try{

   // variable

   int gall;

   double cost=0;

       // object to read value from user

    Scanner scr=new Scanner(System.in);

     // ask user to enter type

    System.out.print("Enter customer type  (R for residential or B for business ):");

    // read type of customer

       char t=scr.next().charAt(0);

       if(t=='r'||t=='R')

       {

           System.out.print("enter the number of gallons:");

           //read number of gallons

           gall=scr.nextInt();

           // if number of gallons are less or equal to 6000

           if(gall<=6000)

            {

           // calculate cost

           cost=gall*0.007;

           // print cost

           System.out.println("total cost is: "+cost);

             }

           else

           {

           // calculate cost

            cost=(6000*0.005)+((gall-6000)*0.007);

            // print cost

            System.out.println("total cost is: "+cost);

           }

       }

       else if(t=='b'||t=='B')

       {

           System.out.print("enter the number of gallons:");

           //read number of gallons

           gall=scr.nextInt();

           // if number of gallons are less or equal to 8000

           if(gall<=8000)

            {

           // calculate cost

           cost=gall*0.006;

           // print cost

           System.out.println("total cost is: "+cost);

             }

           else

           {// calculate cost

            cost=(8000*0.006)+((gall-8000)*0.008);

            // print cost

            System.out.println("total cost is: "+cost);

           }

       }

   }catch(Exception ex){

       return;}

}

}

Explanation:

Ask user to enter the type of customer and assign it to variable "t" with scanner object.If the customer type is business then read the number of gallons from user and assign it to variable "gall". Then calculate cost of gallons, if   gallons are less or equal to 8000 then multiply it with 0.006.And if gallons are greater than 8000, cost for  first 8000 will be multiply by 0.006 and   for rest gallons multiply with 0.008.Similarly if customer type is residential then for first 6000 gallons cost will be multiply by 0.005 and for rest it will  multiply by 0.007. Then print the cost.

Output:

Enter customer type  (R for residential or B for business ):r

enter the number of gallons:8000

total cost is: 44.0

Write a function copy that takes two arrays A and B, both of size N. The function then copies all N values from A into B and then displays it.

Answers

Answer:

Written in C++

#include<iostream>

using namespace std;

int main()

{

int N;

cout<<"Length of Array: ";

cin>>N;

int A[N], B[N];

for(int i =0;i<N;i++)  {

 cin>>A[i];

}

for(int i =0;i<N;i++)  {

 B[i] = A[i];

}

for(int i =0;i<N;i++)  {

 cout<<B[i]<<" ";

}  

return 0;

}

Explanation:

This line declares the length of the Array; N

int N;

This line prompts user for length of array

cout<<"Length of Array: ";

This line gets user input for length of array

cin>>N;

This line declares array A and B

int A[N], B[N];

The following iteration gets input for Array A

for(int i =0;i<N;i++)  {

 cin>>A[i];

}

The following iteration gets copies element of Array A to Array B

for(int i =0;i<N;i++)  {

 B[i] = A[i];

}

The following iteration prints elements of Array B

for(int i =0;i<N;i++)  {

 cout<<B[i]<<" ";

}  

Consider the following class definition.public class Tester
{
privtae int num1;
private int num2;
/missing constructor /
}
The following statement appears in a method in a class other than Tester. It is intended t o create a new Tester object t with its attributes set to 10 and 20.
Tester t = new Tester(10,20);

Which can be used to replace / missing constructor / so that the object t is correctly created?

Answers

Answer:

Explanation:

The following constructor needs to be added to the code so that the object called t can be created correctly...

public Tester(int arg1, int arg2) {

    num1 = arg1;

    num2 = arg2;

}

This basic constructor will allow the object to be created correctly and will take the two arguments passed to the object and apply them to the private int variables in the class. The question does not state what exactly the Tester constructor is supposed to accomplish so this is the basic format of what it needs to do for the object to be created correctly.

Following a security assessment, the Chief Information Security Officer (CISO) is reviewing the results of the assessment and evaluating potential risk treatment strategies. As part of the CISO’s evaluation, a judgment of potential impact based on the identified risk is performed. To prioritize response actions, the CISO uses past experience to take into account the exposure factor as well as the external accessibility of the weakness identified. Which of the following is the CISO performing?A. Documentation of lessons learned
B. Quantitative risk assessment
C. Qualitative assessment of risk
D. Business impact scoring
E. Threat modeling

Answers

Answer:

The correct answer to the following question is option B). Quantitative risk assessment.

Explanation:

QRA ( Quantitative Risk assessment) is the objective risk  assessment tool that is used to project threat impacts.

Quantitative Risk Assessment provides the estimate of magnitude of the consequences for each of the identified budget threats.

It set out to measure, define, provide, and predict the confidence  level of the likelihood and the occurrence of the threat impacts.

Which of the following statements describes a limitation of using a computer simulation to model a real-world object or system?a. Computer simulations can only be built after the real-world object or system has been created.
b. Computer simulations only run on very powerful computers that are not available to the general public.
c. Computer simulations usually make some simplifying assumptions about the real-world object or system being modeled.

Answers

Answer:

The answer is "Option c".

Explanation:

Computer simulation, use of a machine to simulate a system's vibration signals by another modeled system's behaviors. A simulator employs a computer program to generate a mathematical model or representation of a true system. It usually gives a lot of simplifications concerning the physical image or system that is modeled, so this statement describes the limitation of using a computer simulation in modeling a real-world object or process.