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
Westkost [7]
3 years ago
14

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.". Sample output with input: 2
Computers and Technology
1 answer:
Mama L [17]3 years ago
7 0

Answer:

def shampoo_instructions(num_cycles):

   #Check the cycles to be greater than 1.

   if num_cycles < 1:

     

       #Display the statement.

       print('Too few.')

     

   #Check the cycles to be greater than 4.

   elif num_cycles > 4:

     

       #Display the statement.

       print('Too many.')

     

   #The else part.

   else:

     

       #Initialize the variable.

       N = 1;

         

       #Begin the for loop.

       for N in range(N, num_cycles+1):

         

           #Print the result.

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

         

       #Print the statement.

       print('Done.')

#Call the function.

shampoo_instructions(2)

Explanation:

You might be interested in
Users can customize sparklines In Excel 2016 using which items? Choose two answers Here are the possible answers: Location , sty
andriy [413]

formula and styles maybe

4 0
4 years ago
What if the world was made of Jello?
Yanka [14]
That’d be pretty cool
6 0
2 years ago
The alpha channel is a color component that determines the degree of opacity/transparency of a color.
denis-greek [22]
THIS ANSWER IS FALSE......
7 0
4 years ago
Read 2 more answers
In which of the following movies, multimedia's special effect is used ? *
Mila [183]

\qquad \qquad\huge \underline{\boxed{\sf Answer}}

The Correct choice is ~ D

In all these movies, multimedia's special effects are used

5 0
2 years ago
Read 2 more answers
30 points) Suppose you are given a string containing only the characters ( and ). In this problem, you will write a function to
navik [9.2K]

Answer:

The screenshot is attached below

Explanation:

The below program check balence of paranthesis using stack.

if the input charecter is ( then push to stack

if the input charecter is ) then pop top element and compair both elements for match.

Program:

public class Main

{

static class stack // create class for stack

{

int top=-1; // initialy stack is empty so top = -1

char items[] = new char[50]; // Create an array for stack to store stack elements

 

void push(char a) // Function push element to stack

{

if (top == 49) // chack stack is full ?

{

System.out.println("Stack full");

}

else

{

items[++top] = a; // increment the array index and store the element

}

}

 

char pop() // function to return the elements from stack

{

if (top == -1) // check the stack is empty

{

System.out.println("Empty stack");

return '\0';

}

else

{

char element = items[top]; // return the top element

top--; // Decrement the array index by one

return element;

}

}

 

boolean isEmpty() // Check the stack is empty or not

{

return (top == -1) ? true : false;

}

}

static boolean isMatch(char character1, char character2) // Check the input charecters are matching pairs or not

{

if (character1 == '(' && character2 == ')') // If they match return true

return true;

else

return false;

}

 

static boolean isBalanced(String parantheses) // check the input string is balenced or not

{

char[] exp = new char[parantheses.length()]; // Create a charecter array

for (int i = 0; i < parantheses.length(); i++) { // Convert the string parantheses to charecter array

exp[i] = parantheses.charAt(i);

}

stack st=new stack(); // Declare an empty character stack    

for(int i=0;i<exp.length;i++)

{  

if (exp[i] == '('))   // if input charecter is '(' push to stack

st.push(exp[i]);

if (exp[i] == ')') // if input charecter is ')' pop top element from stack

{

if (st.isEmpty())

{

return false;

}

 

else if ( !isMatch(st.pop(), exp[i]) ) // Call isMatch function

{

return false;

}

}

 

}

 

if (st.isEmpty())

return true; //balanced

else

{

return false; //not balanced

}

}

 

 

public static void main(String[] args)

{

 

System.out.println(isBalanced("()()()")); // Output true if string is balenced

 

}

 

}

Screenshot:

5 0
3 years ago
Other questions:
  • Task manager is showing an application as “not responding.” what can you do?
    11·1 answer
  • COMPUTER ORGANIZATION &amp; ARCHITECTURE I<br>please help need the correct answers to all
    6·1 answer
  • What Windows Server 2016 edition is used for volume licensing customers in academic markets and allows multiple users to share o
    9·1 answer
  • If you write a toString method to display the contents of an object, object1, for a class, Class1, then the following two statem
    7·1 answer
  • Which is a reason why an organization might get rid of its entire information processing unit?
    10·1 answer
  • Describe how learning can be accessed in your class?​
    14·1 answer
  • 2. Which pattern microphone should Jennifer take to the press conference? Jennifer is a journalist with one of the leading newsp
    14·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    12·2 answers
  • Only need help on f and correct me if im wrong for the other questions please
    11·1 answer
  • How many devices can I sign in on with my one Brainly account?
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!