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
daser333 [38]
3 years ago
5

Use python

Computers and Technology
1 answer:
konstantin123 [22]3 years ago
6 0

Answer:

Here is the Python program:

def exec_2(f):

    f()

    f()

   

def exec_4(f):

    exec_2(f)

    exec_2(f)

   

def print_koala():

    print("koala")    

exec_4(print_koala)

Explanation:

The program works as follows:

First method:

def exec_2(f):

f()

f()

any function that is passed into exec_2() will be executed twice without parameters.

Second method:

def exec_4(f):

    exec_2(f)

    exec_2(f)

function exec_4(f) takes in a function f as a parameter and executes the function f 4 times using the function exec_2. At first exec_2(f) call the function f is executed twice and and second exec_2(f) call the function f is again executed twice so the function f executes 4 times in total.

Third method:

def print_koala():

    print("koala")  

a function that prints out the koala once

This function has a print statement which is passed the string koala to print on output screen.

exec_4(print_koala)

function exec_4 is used to print koala four times. This function exec_4 takes as argument the function print_koala() So this works as follows:

exec_4(print_koala)

The body of exec_4 executes as:

exec_2(print_koala)

exec_2(print_koala)

Now at first call to exec_2(print_koala) the program moves to the function exec_2 which executes print_koala()  method twice. Since print_koala() method has a print statement print("koala") so this is executed twice:

koala                                                                                                                                           koala

Now at second call exec_2(print_koala) the program moves to the function exec_2 which executes print_koala()  method twice again. Since print_koala() method has a print statement print("koala") so this is executed again twice:

koala                                                                                                                                           koala

So the output of the entire above program is:

koala                                                                                                                                           koala                                                                                                                                           koala                                                                                                                                           koala

The screenshot of program along with its output is attached.

You might be interested in
Robert and Anne, a married couple filing jointly, have an adjusted gross income of $68,676. They claim two exemptions, and can d
artcher [175]

Answer:

the answer is B

Explanation:

Just took the test

8 0
2 years ago
Read 2 more answers
I have a question about my HP Laptop
vekshin1
What exactly is your question?
7 0
3 years ago
Place the following STEM inventions in the correct chronological order, from the earliest to the most recent discovery.
sukhopar [10]
Probably C

If I’m right, can you mark me brainliest please?
5 0
2 years ago
Read 2 more answers
The best way for you to communicate with the school is through
REY [17]
A. Because you can easily call the school without wasting too much time
4 0
3 years ago
Steps for turning off 2 step verification on iPhones
jeka94
If it’s for the App Store, follow this
Settings > ITunes & Apple Store > Password Settings > Turn off require password by pressing the swipe button thing. I’m sorry if this doesn’t help
6 0
3 years ago
Other questions:
  • The first digital keyboard was the DX-7, introduced by the Yamaha company in 1983.
    15·1 answer
  • I need someone whos really good with computers to help me with some things
    12·1 answer
  • ________ are found on the motherboard and are used to attach your hard disk.
    6·1 answer
  • Which type of operating system is usually used in personal computers?
    11·1 answer
  • Why is it a good idea to leave an interview being courteous and polite?
    10·1 answer
  • Stealing passwords by using software code to run through various password schemes with numbers, symbols, capital letters, and ch
    6·1 answer
  • Write the algorithm and draw a flowchart to display the greatest number among any two different numbers....
    5·1 answer
  • What is wrong with the following code? publicstatic char grade(int score) { if (score >= 9) { return 'A'; } else if (score &g
    6·1 answer
  • Deirdre has a hearing disability. One of her friends advised her to use real-time text or RTT on her phone. In which of these
    13·1 answer
  • Travelers should keep their profile information up-to-date. which is not an option for a traveler to update their own profile in
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!