Here is another example that uses do_twice to call a function named print_apple twice. def print_apple() : print('apple') do_twice(print_apple) 1. Type this example into a script and test it. 2. Modify do_twice so that it takes two arguments, a function object and a value, and calls the function twice, passing the value as an argument.

Respuesta :

The program is an illustration of a python function.

Python functions are used to group code segments in a block

Test the script

To do this, we simply run the following program:

def do_twice(f):

  f()

  f()

def print_apple() :

  print('apple')

do_twice(print_apple)

Modify do_twice()

The modification is to allow the function to take two parameters, which are:

  • Function object
  • Value

The modified function is as follows:

fruit= raw_input('Input fruit to repeat: ')

def do_twice(f, fruit):

  f(fruit)

  f(fruit)

def print_apple(fruit) :

  print fruit

do_twice(print_apple, fruit)

Read more about python programs at:

https://brainly.com/question/13246781

#SPJ1

Missing part of the question

A function object is a value you can assign to a variable or pass as an argument. For example, do_twice is a function that takes a function object as an argument and calls it twice:

def do_twice(f):

    f()

    f()