4.7k views
3 votes
Define a function make_demanding that consumes a string and returns a new, more demanding string. To make a string more demanding, add the string ", now!" to the end. For example, the string "Pass the butter" would become "Pass the butter, now!". Note: Your function will be unit tested against multiple strings. It is not enough to get the right output for your own test cases, you will need to be able to handle any kind of non-empty string.

1 Answer

3 votes

Answer:

The program to this question can be given as:

Program:

def make_demanding(x1): #define a function.

x1 = x1 + ", now!" #add value in x1 variable

return x1 # return value.

print(make_demanding("Pass the butter")) #call function and print message.

Output:

Pass the butter, now!

Explanation:

The description of the above python program as follows:

  • In the above program, we define a function that is "make_demanding". In python, we use the def keyword to define a function in this function we pass a variable that is "x1".
  • Inside a function we use the passed variable and add a value to this variable that is ", now!" and return its value.
  • Then we use the print function that is used for print value on the console screen. Inside the print function, we call the make_demanding method and pass the string value in a parameter that is "Pass the butter".

User Ro Marcus Westin
by
5.7k points