1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
avanturin [10]
3 years ago
15

Write a function shampoo_instructions() with parameter num_cycles. If num_cycles is less than 1, print "Too few.". If more than

4, print "Too many.". Else, print "N : Lather and rinse." num_cycles times, where N is the cycle number, followed by "Done.".
Computers and Technology
1 answer:
EastWind [94]3 years ago
6 0

Answer:

Following are the code to the given question:

def shampoo_instructions(num_cycles):#defining a method shampoo_instructions that accepts num_cycles as a parameter

   if num_cycles < 1:#defining an if block that num_cycles value is less than 1

       print('Too few.')#print message  

   elif num_cycles > 4:#defining elif block that checks num_cycles is greater than 4

       print('Too many.')#print message  

   else:#defining else block

       N= 1;#defining N variable that holds a value 1

       for N in range(N, num_cycles+1):#defining for loop that check value in range

           print(N , ": Lather and rinse.")#print message  

       print('Done.')#print message  

shampoo_instructions(2)#calling the method

Output:

1 : Lather and rinse.

2 : Lather and rinse.

Done.

Explanation:

In this code, a method "shampoo_instructions" is defined, that accepts a variable "num_cycles" in its parameter, and in the next step, the multiple conditional statements have used that check the "num_cycles" values which can be defined as follows:

  • The if the block checks the parameter value is less than 1, and it prints the value as the message.
  • In the next step, the elif block is used that checks parameter value is greater than 4, and it prints the value as the message.
  • In the else block, it uses the for loop that checks the value in the range and prints its value and calling the method.
You might be interested in
You want to be able to identify the services running on a set of servers on your network. Which tool would best give you the inf
puteri [66]

Answer:

Vulnerability scanner

5 0
3 years ago
. Write a function definition as follows: it returns the C++ form of a Boolean value, its function identifier is anyTwoTheSame,
Paraphin [41]

Answer:

The c++ code to implement the Boolean function is given. The function definition is shown.

bool anyTwoTheSame(float a, float b, float c)

{

   bool same = false;    

   if(a == b)

       same = true;

   else if(a == c)

       same = true;

   else if(b == c)

       same = true;        

   return same;

}

Explanation:

This function accepts three floating point numbers and returns true if any two numbers are equal else returns false.

The program below shows the implementation of this method.

#include <iostream>

using namespace std;

bool anyTwoTheSame(float a, float b, float c);

bool anyTwoTheSame(float a, float b, float c)

{

   bool same = false;    

   if(a == b)

       same = true;

   else if(a == c)

       same = true;

   else if(b == c)

       same = true;        

   return same;

}

int main() {    

   float one=12.34, two=56.78, three=90.1;    

   cout<<"Two numbers are same : " <<anyTwoTheSame(one, two, three);

}

OUTPUT

Two numbers are same : 0

The method is first declared.

bool anyTwoTheSame(float a, float b, float c);

Next step is method definition which shows what the function is supposed to do. The test to check equality of two numbers is implemented as shown.

bool same = false;    

if(a == b)

       same = true;

   else if(a == c)

       same = true;

   else if(b == c)

       same = true;  

This is the simplest test which can be programmed.

If the numbers are not same, the Boolean variable, same, remains initialized to false.

This function is then called in main method.

No user input is taken as this is not specified in the question.

The three floating variables are declared and initialized inside the main. The values are put inside the program and not taken from the user.

The output shows either 0 or 1. 0 represents false and 1 represents true.

This program can be tested for different values of floating variables.

3 0
3 years ago
Data warehousing is a(n) __________, and data mining is a(n) ____________.
Maksim231197 [3]

Answer:

B. Process, group of techniques

Explanation:

Data warehousing simply means storing large amounts of data from multiple sources to a central "warehouse" to be analyzed or simply stored for later. Data mining on the other hand involves discovering patterns in sets of data to make better decisions. Analyzing data with a group of techniques like statistics and machine learning.

8 0
3 years ago
Lola wants to install an add-in in Excel.She has to unblock the add-in to allow Excel to open the add-in file automatically.To d
ololo11 [35]

Answer:

The correct answer is:

Properties (D)

Explanation:

First of all, option D (Properties) is the option that makes the most sense in this scenario, because the other options: Copy, Delete, and Rename are unrelated commands to what is to be achieved.

Secondly and more practically, an add-in file may not load in excel, and most of the time it is blocked by default and has to be unblocked. The following steps are used:

1. close Excel if it is open

2. open the folder where the add-in file is located, right-click on the add-in file, and select "properties"

3. a display tray will appear, having the attributes: Read-only, Hidden, Advanced, and unblock. Click the checkbox against "unblock" and make sure it is checked.

4. click Apply and Click Ok

Voila, your add-in file is unblocked.

<em>N:B The Images are for steps 2 and 3</em>

5 0
3 years ago
Just trying to pass this class
liq [111]

Answer:

A. Your Foreman

Explanation:

They should be trained on whatever you are doing

4 0
3 years ago
Other questions:
  • Which type of system must you connect to and use to make changes to Active Directory?
    15·1 answer
  • Percy is a lighting technician in a film production. For a shot, the chief lighting technician instructs Percy to get the kind o
    15·1 answer
  • What is the digital divide? What does the digital divide mean for the world?
    9·1 answer
  • Write an application named [LastName]_MultiplicationTable and create a method that prompts the user for an integer value, for ex
    11·1 answer
  • The hardware to keep the output data when finished is a
    9·1 answer
  • What is the difference between a try block and a try statement? Group of answer choices There is no difference; the terms can be
    6·1 answer
  • Select the correct answer
    5·2 answers
  • What type of computer is used in ATM?
    11·2 answers
  • Hey guys i need help again on coding
    7·1 answer
  • (25 POINTS) Some applications work on all devices while others work on some devices. True or False?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!