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
Elden [556K]
2 years ago
10

Here is another example that uses do_twice to call a function named print_apple twice. def print_apple() : print('apple') do_twi

ce(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.
Computers and Technology
1 answer:
natima [27]2 years ago
5 0

The program is an illustration of a python function.

Python functions are used to group code segments in a block

<h3>Test the script</h3>

To do this, we simply run the following program:

def do_twice(f):

  f()

  f()

def print_apple() :

  print('apple')

do_twice(print_apple)

<h3>Modify do_twice()</h3>

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:

brainly.com/question/13246781

#SPJ1

<u>Missing part of the question</u>

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()

You might be interested in
Your boss calls you in a panic. he said he just deleted three paragraphs and doesn t know how to bring them back. what do you te
Ipatiy [6.2K]
Undo is Ctrl-Z. Undo buttons also exist in most non-Notepad text editing programs.
5 0
3 years ago
g Write a program that reads a list of words, and a character. The output of the program is every word in the list of words that
lord [1]

Answer:

Here you go, alter this as you see fit :)

Explanation:

array = []

cnt = 0

while cnt < 11:

   x = input("Enter a word: ")

   array.append(x)

   cnt += 1

   y = input("Add another word?(Y/n):  ")

   if y.lower() == "n":

       break

letter = input("\nChoose a letter: ")

if len(letter) != 1:

   print("Error: too many characters")

   quit()

for n in range(len(array)):

   if letter.lower() in array[n].lower():

       print(array[n], end= ",")

4 0
3 years ago
Write a program to implement the algorithm that you designed in Exercise 21 of Chapter 1. Your program should allow the user to
Murrr4er [49]

Answer:

total = 0

items = int(input("Enter the number of items ordered: "))

for i in range(items):

   price = float(input("Enter the price of item " + str(i+1) + ": "))

   total += price

if total < 200:

   total += (items * 10)

   

print("Bill is $" + str(total))

Explanation:

*The code is in Python.

Ask the user to enter the number of items ordered

Create a for loop that iterates depending on the number of items ordered. Inside the loop, ask the price of each item and add it to the total

After the loop, check the total. If it is smaller than 200, add 10 for each item to the total

Print the total

4 0
4 years ago
4. _______ are miniature versions of the slides in a presentation. A. ScreenTips B. Thumbnails C. Window controls D. Shapes
Ber [7]
B.
Thumbnails is correct
6 0
4 years ago
Read 2 more answers
Qual a diferença entre a luz e o sol​
Oksanka [162]

Responder:

La luz es algo que ilumina, pero el sol es un calor que ilumina todo el universo.

¿Eso ayuda?

7 0
3 years ago
Other questions:
  • .exe, .msi, .msp, .inf - together, what do these filetypes indicate
    12·2 answers
  • What is a characteristic of high-level computer programming languages?
    8·1 answer
  • Meaning of page break​
    8·1 answer
  • A compression scheme for long strings of bits called run-length encoding is described as follows: Rather than record each 0 and
    8·1 answer
  • Which of the following files has the Ionic styles? ionic.bundle.css ionic.js ionic.css ionic.bundle.js
    13·1 answer
  • Refer to the exhibit. One end of the cable is terminated as displayed, and the other end is terminated in accordance with the T5
    7·1 answer
  • Please help me. i will mark you brailiest
    6·1 answer
  • How can you ensure that the website you are using is secured?
    8·1 answer
  • The _____ of a story describes the time and location of a story.
    5·2 answers
  • To remove a specified number of characters from anywhere within a string, you should use the ____ method.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!